<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE BangPatterns, CPP, RecordWildCards, ScopedTypeVariables #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE Trustworthy #-}</span><span>
</span><span id="line-3"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-4"></span><span class="hs-comment">-- Module      : Data.Text.IO</span><span>
</span><span id="line-5"></span><span class="hs-comment">-- Copyright   : (c) 2009, 2010 Bryan O'Sullivan,</span><span>
</span><span id="line-6"></span><span class="hs-comment">--               (c) 2009 Simon Marlow</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- License     : BSD-style</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- Maintainer  : bos@serpentine.com</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- Portability : GHC</span><span>
</span><span id="line-10"></span><span class="hs-comment">--</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- Efficient locale-sensitive support for text I\/O.</span><span>
</span><span id="line-12"></span><span class="hs-comment">--</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- Skip past the synopsis for some important notes on performance and</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- portability across different versions of GHC.</span><span>
</span><span id="line-15"></span><span>
</span><span id="line-16"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Data.Text.IO</span><span>
</span><span id="line-17"></span><span>    </span><span class="hs-special">(</span><span>
</span><span id="line-18"></span><span>    </span><span class="annot"><span class="hs-comment">-- * Performance</span></span><span>
</span><span id="line-19"></span><span>    </span><span class="annot"><span class="hs-comment">-- $performance</span></span><span>
</span><span id="line-20"></span><span>
</span><span id="line-21"></span><span>    </span><span class="annot"><span class="hs-comment">-- * Locale support</span></span><span>
</span><span id="line-22"></span><span>    </span><span class="hs-comment">-- $locale</span><span>
</span><span id="line-23"></span><span>    </span><span class="hs-comment">-- * File-at-a-time operations</span><span>
</span><span id="line-24"></span><span>      </span><span class="annot"><a href="Data.Text.IO.html#readFile"><span class="hs-identifier">readFile</span></a></span><span>
</span><span id="line-25"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.IO.html#writeFile"><span class="hs-identifier">writeFile</span></a></span><span>
</span><span id="line-26"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.IO.html#appendFile"><span class="hs-identifier">appendFile</span></a></span><span>
</span><span id="line-27"></span><span>    </span><span class="annot"><span class="hs-comment">-- * Operations on handles</span></span><span>
</span><span id="line-28"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.IO.html#hGetContents"><span class="hs-identifier">hGetContents</span></a></span><span>
</span><span id="line-29"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.IO.html#hGetChunk"><span class="hs-identifier">hGetChunk</span></a></span><span>
</span><span id="line-30"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.IO.html#hGetLine"><span class="hs-identifier">hGetLine</span></a></span><span>
</span><span id="line-31"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.IO.html#hPutStr"><span class="hs-identifier">hPutStr</span></a></span><span>
</span><span id="line-32"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.IO.html#hPutStrLn"><span class="hs-identifier">hPutStrLn</span></a></span><span>
</span><span id="line-33"></span><span>    </span><span class="annot"><span class="hs-comment">-- * Special cases for standard input and output</span></span><span>
</span><span id="line-34"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.IO.html#interact"><span class="hs-identifier">interact</span></a></span><span>
</span><span id="line-35"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.IO.html#getContents"><span class="hs-identifier">getContents</span></a></span><span>
</span><span id="line-36"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.IO.html#getLine"><span class="hs-identifier">getLine</span></a></span><span>
</span><span id="line-37"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.IO.html#putStr"><span class="hs-identifier">putStr</span></a></span><span>
</span><span id="line-38"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.IO.html#putStrLn"><span class="hs-identifier">putStrLn</span></a></span><span>
</span><span id="line-39"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-40"></span><span>
</span><span id="line-41"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Text.html"><span class="hs-identifier">Data.Text</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier">Text</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-42"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Prelude.html#"><span class="hs-identifier">Prelude</span></a></span><span> </span><span class="hs-keyword">hiding</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/System.IO.html#appendFile"><span class="hs-identifier">appendFile</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/System.IO.html#getContents"><span class="hs-identifier">getContents</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/System.IO.html#getLine"><span class="hs-identifier">getLine</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/System.IO.html#interact"><span class="hs-identifier">interact</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-43"></span><span>                       </span><span class="annot"><a href="../../base/src/System.IO.html#putStr"><span class="hs-identifier">putStr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/System.IO.html#putStrLn"><span class="hs-identifier">putStrLn</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/System.IO.html#readFile"><span class="hs-identifier">readFile</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/System.IO.html#writeFile"><span class="hs-identifier">writeFile</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-44"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/System.IO.html#"><span class="hs-identifier">System.IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier">Handle</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.IOMode.html#IOMode"><span class="hs-identifier">IOMode</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Text.html#hPutChar"><span class="hs-identifier">hPutChar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.StdHandles.html#openFile"><span class="hs-identifier">openFile</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.StdHandles.html#stdin"><span class="hs-identifier">stdin</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.StdHandles.html#stdout"><span class="hs-identifier">stdout</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-45"></span><span>                  </span><span class="annot"><a href="../../base/src/System.IO.html#withFile"><span class="hs-identifier">withFile</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-46"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../base/src/Control.Exception.html#"><span class="hs-identifier">Control.Exception</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">E</span></span><span>
</span><span id="line-47"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#liftM2"><span class="hs-identifier">liftM2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier">when</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-48"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.IORef.html#"><span class="hs-identifier">Data.IORef</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IORef.html#readIORef"><span class="hs-identifier">readIORef</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IORef.html#writeIORef"><span class="hs-identifier">writeIORef</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-49"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="Data.Text.html"><span class="hs-identifier">Data.Text</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">T</span></span><span>
</span><span id="line-50"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Text.Internal.Fusion.html"><span class="hs-identifier">Data.Text.Internal.Fusion</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Internal.Fusion.html#stream"><span class="hs-identifier">stream</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Text.Internal.Fusion.Types.html"><span class="hs-identifier">Data.Text.Internal.Fusion.Types</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Internal.Fusion.Types.html#Step"><span class="hs-identifier">Step</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Internal.Fusion.Types.html#Stream"><span class="hs-identifier">Stream</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-52"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Text.Internal.IO.html"><span class="hs-identifier">Data.Text.Internal.IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Internal.IO.html#hGetLineWith"><span class="hs-identifier">hGetLineWith</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Internal.IO.html#readChunk"><span class="hs-identifier">readChunk</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-53"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Buffer.html#"><span class="hs-identifier">GHC.IO.Buffer</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.Buffer.html#Buffer"><span class="hs-identifier">Buffer</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Buffer.html#BufferState"><span class="hs-identifier">BufferState</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Buffer.html#CharBufElem"><span class="hs-identifier">CharBufElem</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Buffer.html#CharBuffer"><span class="hs-identifier">CharBuffer</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-54"></span><span>                      </span><span class="annot"><a href="../../base/src/GHC.IO.Buffer.html#RawCharBuffer"><span class="hs-identifier">RawCharBuffer</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Buffer.html#emptyBuffer"><span class="hs-identifier">emptyBuffer</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Buffer.html#isEmptyBuffer"><span class="hs-identifier">isEmptyBuffer</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Buffer.html#newCharBuffer"><span class="hs-identifier">newCharBuffer</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-55"></span><span>                      </span><span class="annot"><a href="../../base/src/GHC.IO.Buffer.html#writeCharBuf"><span class="hs-identifier">writeCharBuf</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-56"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#"><span class="hs-identifier">GHC.IO.Exception</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#IOException"><span class="hs-identifier">IOException</span></a></span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#ioe_type"><span class="hs-identifier">ioe_type</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#IOErrorType"><span class="hs-identifier">IOErrorType</span></a></span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#InappropriateType"><span class="hs-identifier">InappropriateType</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-57"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Internals.html#"><span class="hs-identifier">GHC.IO.Handle.Internals</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Internals.html#augmentIOError"><span class="hs-identifier">augmentIOError</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Internals.html#hClose_help"><span class="hs-identifier">hClose_help</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Internals.html#wantReadableHandle"><span class="hs-identifier">wantReadableHandle</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-58"></span><span>                                </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Internals.html#wantWritableHandle"><span class="hs-identifier">wantWritableHandle</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-59"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Text.html#"><span class="hs-identifier">GHC.IO.Handle.Text</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Text.html#commitBuffer%27"><span class="hs-identifier">commitBuffer'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-60"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#"><span class="hs-identifier">GHC.IO.Handle.Types</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#BufferList"><span class="hs-identifier">BufferList</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#BufferMode"><span class="hs-identifier">BufferMode</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier">Handle__</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-61"></span><span>                            </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#HandleType"><span class="hs-identifier">HandleType</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Newline"><span class="hs-identifier">Newline</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-62"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/System.IO.html#"><span class="hs-identifier">System.IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.Handle.html#hGetBuffering"><span class="hs-identifier">hGetBuffering</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.html#hFileSize"><span class="hs-identifier">hFileSize</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.html#hSetBuffering"><span class="hs-identifier">hSetBuffering</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.html#hTell"><span class="hs-identifier">hTell</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-63"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/System.IO.Error.html#"><span class="hs-identifier">System.IO.Error</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/System.IO.Error.html#isEOFError"><span class="hs-identifier">isEOFError</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-64"></span><span>
</span><span id="line-65"></span><span class="hs-comment">-- $performance</span><span>
</span><span id="line-66"></span><span class="hs-comment">-- #performance#</span><span>
</span><span id="line-67"></span><span class="hs-comment">--</span><span>
</span><span id="line-68"></span><span class="hs-comment">-- The functions in this module obey the runtime system's locale,</span><span>
</span><span id="line-69"></span><span class="hs-comment">-- character set encoding, and line ending conversion settings.</span><span>
</span><span id="line-70"></span><span class="hs-comment">--</span><span>
</span><span id="line-71"></span><span class="hs-comment">-- If you know in advance that you will be working with data that has</span><span>
</span><span id="line-72"></span><span class="hs-comment">-- a specific encoding (e.g. UTF-8), and your application is highly</span><span>
</span><span id="line-73"></span><span class="hs-comment">-- performance sensitive, you may find that it is faster to perform</span><span>
</span><span id="line-74"></span><span class="hs-comment">-- I\/O with bytestrings and to encode and decode yourself than to use</span><span>
</span><span id="line-75"></span><span class="hs-comment">-- the functions in this module.</span><span>
</span><span id="line-76"></span><span class="hs-comment">--</span><span>
</span><span id="line-77"></span><span class="hs-comment">-- Whether this will hold depends on the version of GHC you are using,</span><span>
</span><span id="line-78"></span><span class="hs-comment">-- the platform you are working on, the data you are working with, and</span><span>
</span><span id="line-79"></span><span class="hs-comment">-- the encodings you are using, so be sure to test for yourself.</span><span>
</span><span id="line-80"></span><span>
</span><span id="line-81"></span><span class="hs-comment">-- | The 'readFile' function reads a file and returns the contents of</span><span>
</span><span id="line-82"></span><span class="hs-comment">-- the file as a string.  The entire file is read strictly, as with</span><span>
</span><span id="line-83"></span><span class="hs-comment">-- 'getContents'.</span><span>
</span><span id="line-84"></span><span class="annot"><a href="Data.Text.IO.html#readFile"><span class="hs-identifier hs-type">readFile</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span>
</span><span id="line-85"></span><span id="readFile"><span class="annot"><span class="annottext">readFile :: FilePath -&gt; IO Text
</span><a href="Data.Text.IO.html#readFile"><span class="hs-identifier hs-var hs-var">readFile</span></a></span></span><span> </span><span id="local-6989586621679115946"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679115946"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IOMode -&gt; IO Handle
</span><a href="../../base/src/GHC.IO.StdHandles.html#openFile"><span class="hs-identifier hs-var">openFile</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679115946"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">IOMode
</span><a href="../../base/src/GHC.IO.IOMode.html#ReadMode"><span class="hs-identifier hs-var">ReadMode</span></a></span><span> </span><span class="annot"><span class="annottext">IO Handle -&gt; (Handle -&gt; IO Text) -&gt; IO Text
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO Text
</span><a href="Data.Text.IO.html#hGetContents"><span class="hs-identifier hs-var">hGetContents</span></a></span><span>
</span><span id="line-86"></span><span>
</span><span id="line-87"></span><span class="hs-comment">-- | Write a string to a file.  The file is truncated to zero length</span><span>
</span><span id="line-88"></span><span class="hs-comment">-- before writing begins.</span><span>
</span><span id="line-89"></span><span class="annot"><a href="Data.Text.IO.html#writeFile"><span class="hs-identifier hs-type">writeFile</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-90"></span><span id="writeFile"><span class="annot"><span class="annottext">writeFile :: FilePath -&gt; Text -&gt; IO ()
</span><a href="Data.Text.IO.html#writeFile"><span class="hs-identifier hs-var hs-var">writeFile</span></a></span></span><span> </span><span id="local-6989586621679115944"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679115944"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IOMode -&gt; (Handle -&gt; IO ()) -&gt; IO ()
forall r. FilePath -&gt; IOMode -&gt; (Handle -&gt; IO r) -&gt; IO r
</span><a href="../../base/src/System.IO.html#withFile"><span class="hs-identifier hs-var">withFile</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679115944"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">IOMode
</span><a href="../../base/src/GHC.IO.IOMode.html#WriteMode"><span class="hs-identifier hs-var">WriteMode</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle -&gt; IO ()) -&gt; IO ())
-&gt; (Text -&gt; Handle -&gt; IO ()) -&gt; Text -&gt; IO ()
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(Handle -&gt; Text -&gt; IO ()) -&gt; Text -&gt; Handle -&gt; IO ()
forall a b c. (a -&gt; b -&gt; c) -&gt; b -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#flip"><span class="hs-identifier hs-var">flip</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Text -&gt; IO ()
</span><a href="Data.Text.IO.html#hPutStr"><span class="hs-identifier hs-var">hPutStr</span></a></span><span>
</span><span id="line-91"></span><span>
</span><span id="line-92"></span><span class="hs-comment">-- | Write a string the end of a file.</span><span>
</span><span id="line-93"></span><span class="annot"><a href="Data.Text.IO.html#appendFile"><span class="hs-identifier hs-type">appendFile</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-94"></span><span id="appendFile"><span class="annot"><span class="annottext">appendFile :: FilePath -&gt; Text -&gt; IO ()
</span><a href="Data.Text.IO.html#appendFile"><span class="hs-identifier hs-var hs-var">appendFile</span></a></span></span><span> </span><span id="local-6989586621679115940"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679115940"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IOMode -&gt; (Handle -&gt; IO ()) -&gt; IO ()
forall r. FilePath -&gt; IOMode -&gt; (Handle -&gt; IO r) -&gt; IO r
</span><a href="../../base/src/System.IO.html#withFile"><span class="hs-identifier hs-var">withFile</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679115940"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">IOMode
</span><a href="../../base/src/GHC.IO.IOMode.html#AppendMode"><span class="hs-identifier hs-var">AppendMode</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle -&gt; IO ()) -&gt; IO ())
-&gt; (Text -&gt; Handle -&gt; IO ()) -&gt; Text -&gt; IO ()
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(Handle -&gt; Text -&gt; IO ()) -&gt; Text -&gt; Handle -&gt; IO ()
forall a b c. (a -&gt; b -&gt; c) -&gt; b -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#flip"><span class="hs-identifier hs-var">flip</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Text -&gt; IO ()
</span><a href="Data.Text.IO.html#hPutStr"><span class="hs-identifier hs-var">hPutStr</span></a></span><span>
</span><span id="line-95"></span><span>
</span><span id="line-96"></span><span class="annot"><a href="Data.Text.IO.html#catchError"><span class="hs-identifier hs-type">catchError</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#IOError"><span class="hs-identifier hs-type">IOError</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-97"></span><span id="catchError"><span class="annot"><span class="annottext">catchError :: FilePath -&gt; Handle -&gt; Handle__ -&gt; IOException -&gt; IO (Text, Bool)
</span><a href="Data.Text.IO.html#catchError"><span class="hs-identifier hs-var hs-var">catchError</span></a></span></span><span> </span><span id="local-6989586621679115936"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679115936"><span class="hs-identifier hs-var">caller</span></a></span></span><span> </span><span id="local-6989586621679115935"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679115935"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">{</span><span id="local-6989586621679115914"><span id="local-6989586621679115915"><span id="local-6989586621679115916"><span id="local-6989586621679115917"><span id="local-6989586621679115918"><span id="local-6989586621679115919"><span id="local-6989586621679115920"><span id="local-6989586621679115921"><span id="local-6989586621679115922"><span id="local-6989586621679115923"><span id="local-6989586621679115924"><span id="local-6989586621679115925"><span id="local-6989586621679115926"><span class="annot"><span class="annottext">dev
Maybe TextEncoding
Maybe (TextEncoder enc_state)
Maybe (TextDecoder dec_state)
Maybe (MVar Handle__)
Newline
HandleType
BufferMode
IORef (dec_state, Buffer Word8)
IORef (BufferList CharBufElem)
IORef (Buffer CharBufElem)
IORef (Buffer Word8)
haBufferMode :: Handle__ -&gt; BufferMode
haBuffers :: Handle__ -&gt; IORef (BufferList CharBufElem)
haByteBuffer :: Handle__ -&gt; IORef (Buffer Word8)
haCharBuffer :: Handle__ -&gt; IORef (Buffer CharBufElem)
haCodec :: Handle__ -&gt; Maybe TextEncoding
haDecoder :: ()
haDevice :: ()
haEncoder :: ()
haInputNL :: Handle__ -&gt; Newline
haLastDecode :: ()
haOtherSide :: Handle__ -&gt; Maybe (MVar Handle__)
haOutputNL :: Handle__ -&gt; Newline
haType :: Handle__ -&gt; HandleType
haOtherSide :: Maybe (MVar Handle__)
haOutputNL :: Newline
haInputNL :: Newline
haCodec :: Maybe TextEncoding
haDecoder :: Maybe (TextDecoder dec_state)
haEncoder :: Maybe (TextEncoder enc_state)
haBuffers :: IORef (BufferList CharBufElem)
haCharBuffer :: IORef (Buffer CharBufElem)
haLastDecode :: IORef (dec_state, Buffer Word8)
haBufferMode :: BufferMode
haByteBuffer :: IORef (Buffer Word8)
haType :: HandleType
haDevice :: dev
</span><a href="../../base/src/GHC.IO.Handle.Types.html#haBufferMode"><span class="hs-glyph hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">..</span></a></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hs-special">}</span><span> </span><span id="local-6989586621679115900"><span class="annot"><span class="annottext">IOException
</span><a href="#local-6989586621679115900"><span class="hs-identifier hs-var">err</span></a></span></span><span>
</span><span id="line-98"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">IOException -&gt; Bool
</span><a href="../../base/src/System.IO.Error.html#isEOFError"><span class="hs-identifier hs-var">isEOFError</span></a></span><span> </span><span class="annot"><span class="annottext">IOException
</span><a href="#local-6989586621679115900"><span class="hs-identifier hs-var">err</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-99"></span><span>        </span><span id="local-6989586621679115899"><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679115899"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (Buffer CharBufElem) -&gt; IO (Buffer CharBufElem)
forall a. IORef a -&gt; IO a
</span><a href="../../base/src/GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (Buffer CharBufElem)
</span><a href="#local-6989586621679115921"><span class="hs-identifier hs-var">haCharBuffer</span></a></span><span>
</span><span id="line-100"></span><span>        </span><span class="annot"><span class="annottext">(Text, Bool) -&gt; IO (Text, Bool)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">((Text, Bool) -&gt; IO (Text, Bool))
-&gt; (Text, Bool) -&gt; IO (Text, Bool)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Buffer CharBufElem -&gt; Bool
forall e. Buffer e -&gt; Bool
</span><a href="../../base/src/GHC.IO.Buffer.html#isEmptyBuffer"><span class="hs-identifier hs-var">isEmptyBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679115899"><span class="hs-identifier hs-var">buf</span></a></span><span>
</span><span id="line-101"></span><span>                 </span><span class="hs-keyword">then</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text
</span><a href="Data.Text.Internal.html#empty"><span class="hs-identifier hs-var">T.empty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#True"><span class="hs-identifier hs-var">True</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-102"></span><span>                 </span><span class="hs-keyword">else</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CharBufElem -&gt; Text
</span><a href="Data.Text.Show.html#singleton"><span class="hs-identifier hs-var">T.singleton</span></a></span><span> </span><span class="annot"><span class="annottext">CharBufElem
</span><span class="hs-char">'\r'</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#True"><span class="hs-identifier hs-var">True</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-103"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IOException -&gt; IO (Text, Bool)
forall e a. Exception e =&gt; e -&gt; IO a
</span><a href="../../base/src/GHC.IO.html#throwIO"><span class="hs-identifier hs-var">E.throwIO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOException -&gt; FilePath -&gt; Handle -&gt; IOException
</span><a href="../../base/src/GHC.IO.Handle.Internals.html#augmentIOError"><span class="hs-identifier hs-var">augmentIOError</span></a></span><span> </span><span class="annot"><span class="annottext">IOException
</span><a href="#local-6989586621679115900"><span class="hs-identifier hs-var">err</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679115936"><span class="hs-identifier hs-var">caller</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679115935"><span class="hs-identifier hs-var">h</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-104"></span><span>
</span><span id="line-105"></span><span class="hs-comment">-- | Wrap readChunk and return a value indicating if we're reached the EOF.</span><span>
</span><span id="line-106"></span><span class="hs-comment">-- This is needed because unpack_nl is unable to discern the difference</span><span>
</span><span id="line-107"></span><span class="hs-comment">-- between a buffer with just \r due to EOF or because not enough data was left</span><span>
</span><span id="line-108"></span><span class="hs-comment">-- for decoding. e.g. the final character decoded from the byte buffer was \r.</span><span>
</span><span id="line-109"></span><span class="annot"><a href="Data.Text.IO.html#readChunkEof"><span class="hs-identifier hs-type">readChunkEof</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Buffer.html#CharBuffer"><span class="hs-identifier hs-type">CharBuffer</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-110"></span><span id="readChunkEof"><span class="annot"><span class="annottext">readChunkEof :: Handle__ -&gt; Buffer CharBufElem -&gt; IO (Text, Bool)
</span><a href="Data.Text.IO.html#readChunkEof"><span class="hs-identifier hs-var hs-var">readChunkEof</span></a></span></span><span> </span><span id="local-6989586621679115894"><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679115894"><span class="hs-identifier hs-var">hh</span></a></span></span><span> </span><span id="local-6989586621679115893"><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679115893"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621679115892"><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679115892"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Handle__ -&gt; Buffer CharBufElem -&gt; IO Text
</span><a href="Data.Text.Internal.IO.html#readChunk"><span class="hs-identifier hs-var">readChunk</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679115894"><span class="hs-identifier hs-var">hh</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679115893"><span class="hs-identifier hs-var">buf</span></a></span><span>
</span><span id="line-111"></span><span>                         </span><span class="annot"><span class="annottext">(Text, Bool) -&gt; IO (Text, Bool)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679115892"><span class="hs-identifier hs-var">t</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#False"><span class="hs-identifier hs-var">False</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-112"></span><span>
</span><span id="line-113"></span><span class="hs-comment">-- | /Experimental./ Read a single chunk of strict text from a</span><span>
</span><span id="line-114"></span><span class="hs-comment">-- 'Handle'. The size of the chunk depends on the amount of input</span><span>
</span><span id="line-115"></span><span class="hs-comment">-- currently buffered.</span><span>
</span><span id="line-116"></span><span class="hs-comment">--</span><span>
</span><span id="line-117"></span><span class="hs-comment">-- This function blocks only if there is no data available, and EOF</span><span>
</span><span id="line-118"></span><span class="hs-comment">-- has not yet been reached. Once EOF is reached, this function</span><span>
</span><span id="line-119"></span><span class="hs-comment">-- returns an empty string instead of throwing an exception.</span><span>
</span><span id="line-120"></span><span class="annot"><a href="Data.Text.IO.html#hGetChunk"><span class="hs-identifier hs-type">hGetChunk</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span>
</span><span id="line-121"></span><span id="hGetChunk"><span class="annot"><span class="annottext">hGetChunk :: Handle -&gt; IO Text
</span><a href="Data.Text.IO.html#hGetChunk"><span class="hs-identifier hs-var hs-var">hGetChunk</span></a></span></span><span> </span><span id="local-6989586621679115891"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679115891"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO (Handle__, Text)) -&gt; IO Text
forall a.
FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO (Handle__, a)) -&gt; IO a
</span><a href="../../base/src/GHC.IO.Handle.Internals.html#wantReadableHandle"><span class="hs-identifier hs-var">wantReadableHandle</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hGetChunk&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679115891"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__ -&gt; IO (Handle__, Text)
</span><a href="#local-6989586621679115890"><span class="hs-identifier hs-var">readSingleChunk</span></a></span><span>
</span><span id="line-122"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-123"></span><span>  </span><span id="local-6989586621679115890"><span class="annot"><span class="annottext">readSingleChunk :: Handle__ -&gt; IO (Handle__, Text)
</span><a href="#local-6989586621679115890"><span class="hs-identifier hs-var hs-var">readSingleChunk</span></a></span></span><span> </span><span id="local-6989586621679115889"><span class="annot"><span class="annottext">hh :: Handle__
</span><a href="#local-6989586621679115889"><span class="hs-identifier hs-var">hh</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">{</span><span id="local-6989586621679115868"><span id="local-6989586621679115869"><span id="local-6989586621679115870"><span id="local-6989586621679115871"><span id="local-6989586621679115872"><span id="local-6989586621679115873"><span id="local-6989586621679115874"><span id="local-6989586621679115875"><span id="local-6989586621679115876"><span id="local-6989586621679115877"><span id="local-6989586621679115878"><span id="local-6989586621679115879"><span id="local-6989586621679115880"><span class="annot"><span class="annottext">dev
Maybe TextEncoding
Maybe (TextEncoder enc_state)
Maybe (TextDecoder dec_state)
Maybe (MVar Handle__)
Newline
HandleType
BufferMode
IORef (dec_state, Buffer Word8)
IORef (BufferList CharBufElem)
IORef (Buffer CharBufElem)
IORef (Buffer Word8)
haOtherSide :: Maybe (MVar Handle__)
haOutputNL :: Newline
haInputNL :: Newline
haCodec :: Maybe TextEncoding
haDecoder :: Maybe (TextDecoder dec_state)
haEncoder :: Maybe (TextEncoder enc_state)
haBuffers :: IORef (BufferList CharBufElem)
haCharBuffer :: IORef (Buffer CharBufElem)
haLastDecode :: IORef (dec_state, Buffer Word8)
haBufferMode :: BufferMode
haByteBuffer :: IORef (Buffer Word8)
haType :: HandleType
haDevice :: dev
haBufferMode :: Handle__ -&gt; BufferMode
haBuffers :: Handle__ -&gt; IORef (BufferList CharBufElem)
haByteBuffer :: Handle__ -&gt; IORef (Buffer Word8)
haCharBuffer :: Handle__ -&gt; IORef (Buffer CharBufElem)
haCodec :: Handle__ -&gt; Maybe TextEncoding
haDecoder :: ()
haDevice :: ()
haEncoder :: ()
haInputNL :: Handle__ -&gt; Newline
haLastDecode :: ()
haOtherSide :: Handle__ -&gt; Maybe (MVar Handle__)
haOutputNL :: Handle__ -&gt; Newline
haType :: Handle__ -&gt; HandleType
</span><a href="#local-6989586621679115868"><span class="hs-glyph hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">..</span></a></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hs-special">}</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-124"></span><span>    </span><span id="local-6989586621679115867"><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679115867"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (Buffer CharBufElem) -&gt; IO (Buffer CharBufElem)
forall a. IORef a -&gt; IO a
</span><a href="../../base/src/GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (Buffer CharBufElem)
</span><a href="#local-6989586621679115875"><span class="hs-identifier hs-var">haCharBuffer</span></a></span><span>
</span><span id="line-125"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621679115866"><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679115866"><span class="hs-identifier hs-var">t</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Handle__ -&gt; Buffer CharBufElem -&gt; IO (Text, Bool)
</span><a href="Data.Text.IO.html#readChunkEof"><span class="hs-identifier hs-var">readChunkEof</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679115889"><span class="hs-identifier hs-var">hh</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679115867"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">IO (Text, Bool)
-&gt; (IOException -&gt; IO (Text, Bool)) -&gt; IO (Text, Bool)
forall e a. Exception e =&gt; IO a -&gt; (e -&gt; IO a) -&gt; IO a
</span><a href="../../base/src/GHC.IO.html#catch"><span class="hs-operator hs-var">`E.catch`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; Handle -&gt; Handle__ -&gt; IOException -&gt; IO (Text, Bool)
</span><a href="Data.Text.IO.html#catchError"><span class="hs-identifier hs-var">catchError</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hGetChunk&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679115891"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679115889"><span class="hs-identifier hs-var">hh</span></a></span><span>
</span><span id="line-126"></span><span>    </span><span class="annot"><span class="annottext">(Handle__, Text) -&gt; IO (Handle__, Text)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679115889"><span class="hs-identifier hs-var">hh</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679115866"><span class="hs-identifier hs-var">t</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-127"></span><span>
</span><span id="line-128"></span><span class="hs-comment">-- | Read the remaining contents of a 'Handle' as a string.  The</span><span>
</span><span id="line-129"></span><span class="hs-comment">-- 'Handle' is closed once the contents have been read, or if an</span><span>
</span><span id="line-130"></span><span class="hs-comment">-- exception is thrown.</span><span>
</span><span id="line-131"></span><span class="hs-comment">--</span><span>
</span><span id="line-132"></span><span class="hs-comment">-- Internally, this function reads a chunk at a time from the</span><span>
</span><span id="line-133"></span><span class="hs-comment">-- lower-level buffering abstraction, and concatenates the chunks into</span><span>
</span><span id="line-134"></span><span class="hs-comment">-- a single string once the entire file has been read.</span><span>
</span><span id="line-135"></span><span class="hs-comment">--</span><span>
</span><span id="line-136"></span><span class="hs-comment">-- As a result, it requires approximately twice as much memory as its</span><span>
</span><span id="line-137"></span><span class="hs-comment">-- result to construct its result.  For files more than a half of</span><span>
</span><span id="line-138"></span><span class="hs-comment">-- available RAM in size, this may result in memory exhaustion.</span><span>
</span><span id="line-139"></span><span class="annot"><a href="Data.Text.IO.html#hGetContents"><span class="hs-identifier hs-type">hGetContents</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span>
</span><span id="line-140"></span><span id="hGetContents"><span class="annot"><span class="annottext">hGetContents :: Handle -&gt; IO Text
</span><a href="Data.Text.IO.html#hGetContents"><span class="hs-identifier hs-var hs-var">hGetContents</span></a></span></span><span> </span><span id="local-6989586621679115864"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679115864"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-141"></span><span>  </span><span class="annot"><span class="annottext">Handle -&gt; IO ()
</span><a href="Data.Text.IO.html#chooseGoodBuffering"><span class="hs-identifier hs-var">chooseGoodBuffering</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679115864"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-142"></span><span>  </span><span class="annot"><span class="annottext">FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO (Handle__, Text)) -&gt; IO Text
forall a.
FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO (Handle__, a)) -&gt; IO a
</span><a href="../../base/src/GHC.IO.Handle.Internals.html#wantReadableHandle"><span class="hs-identifier hs-var">wantReadableHandle</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hGetContents&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679115864"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__ -&gt; IO (Handle__, Text)
</span><a href="#local-6989586621679115862"><span class="hs-identifier hs-var">readAll</span></a></span><span>
</span><span id="line-143"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-144"></span><span>  </span><span id="local-6989586621679115862"><span class="annot"><span class="annottext">readAll :: Handle__ -&gt; IO (Handle__, Text)
</span><a href="#local-6989586621679115862"><span class="hs-identifier hs-var hs-var">readAll</span></a></span></span><span> </span><span id="local-6989586621679115861"><span class="annot"><span class="annottext">hh :: Handle__
</span><a href="#local-6989586621679115861"><span class="hs-identifier hs-var">hh</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">{</span><span id="local-6989586621679115841"><span id="local-6989586621679115842"><span id="local-6989586621679115843"><span id="local-6989586621679115844"><span id="local-6989586621679115845"><span id="local-6989586621679115846"><span id="local-6989586621679115847"><span id="local-6989586621679115848"><span id="local-6989586621679115849"><span id="local-6989586621679115850"><span id="local-6989586621679115851"><span id="local-6989586621679115852"><span id="local-6989586621679115853"><span class="annot"><span class="annottext">dev
Maybe TextEncoding
Maybe (TextEncoder enc_state)
Maybe (TextDecoder dec_state)
Maybe (MVar Handle__)
Newline
HandleType
BufferMode
IORef (dec_state, Buffer Word8)
IORef (BufferList CharBufElem)
IORef (Buffer CharBufElem)
IORef (Buffer Word8)
haOtherSide :: Maybe (MVar Handle__)
haOutputNL :: Newline
haInputNL :: Newline
haCodec :: Maybe TextEncoding
haDecoder :: Maybe (TextDecoder dec_state)
haEncoder :: Maybe (TextEncoder enc_state)
haBuffers :: IORef (BufferList CharBufElem)
haCharBuffer :: IORef (Buffer CharBufElem)
haLastDecode :: IORef (dec_state, Buffer Word8)
haBufferMode :: BufferMode
haByteBuffer :: IORef (Buffer Word8)
haType :: HandleType
haDevice :: dev
haBufferMode :: Handle__ -&gt; BufferMode
haBuffers :: Handle__ -&gt; IORef (BufferList CharBufElem)
haByteBuffer :: Handle__ -&gt; IORef (Buffer Word8)
haCharBuffer :: Handle__ -&gt; IORef (Buffer CharBufElem)
haCodec :: Handle__ -&gt; Maybe TextEncoding
haDecoder :: ()
haDevice :: ()
haEncoder :: ()
haInputNL :: Handle__ -&gt; Newline
haLastDecode :: ()
haOtherSide :: Handle__ -&gt; Maybe (MVar Handle__)
haOutputNL :: Handle__ -&gt; Newline
haType :: Handle__ -&gt; HandleType
</span><a href="#local-6989586621679115841"><span class="hs-glyph hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">..</span></a></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hs-special">}</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-145"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679115834"><span class="annot"><span class="annottext">readChunks :: IO [Text]
</span><a href="#local-6989586621679115834"><span class="hs-identifier hs-var hs-var">readChunks</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-146"></span><span>          </span><span id="local-6989586621679115833"><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679115833"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (Buffer CharBufElem) -&gt; IO (Buffer CharBufElem)
forall a. IORef a -&gt; IO a
</span><a href="../../base/src/GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (Buffer CharBufElem)
</span><a href="#local-6989586621679115848"><span class="hs-identifier hs-var">haCharBuffer</span></a></span><span>
</span><span id="line-147"></span><span>          </span><span class="hs-special">(</span><span id="local-6989586621679115832"><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679115832"><span class="hs-identifier hs-var">t</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679115831"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679115831"><span class="hs-identifier hs-var">eof</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Handle__ -&gt; Buffer CharBufElem -&gt; IO (Text, Bool)
</span><a href="Data.Text.IO.html#readChunkEof"><span class="hs-identifier hs-var">readChunkEof</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679115861"><span class="hs-identifier hs-var">hh</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679115833"><span class="hs-identifier hs-var">buf</span></a></span><span>
</span><span id="line-148"></span><span>                         </span><span class="annot"><span class="annottext">IO (Text, Bool)
-&gt; (IOException -&gt; IO (Text, Bool)) -&gt; IO (Text, Bool)
forall e a. Exception e =&gt; IO a -&gt; (e -&gt; IO a) -&gt; IO a
</span><a href="../../base/src/GHC.IO.html#catch"><span class="hs-operator hs-var">`E.catch`</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; Handle -&gt; Handle__ -&gt; IOException -&gt; IO (Text, Bool)
</span><a href="Data.Text.IO.html#catchError"><span class="hs-identifier hs-var">catchError</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hGetContents&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679115864"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679115861"><span class="hs-identifier hs-var">hh</span></a></span><span>
</span><span id="line-149"></span><span>          </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679115831"><span class="hs-identifier hs-var">eof</span></a></span><span>
</span><span id="line-150"></span><span>            </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">[Text] -&gt; IO [Text]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679115832"><span class="hs-identifier hs-var">t</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-151"></span><span>            </span><span class="hs-keyword">else</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679115832"><span class="hs-identifier hs-var">t</span></a></span><span class="annot"><span class="annottext">Text -&gt; [Text] -&gt; [Text]
forall a. a -&gt; [a] -&gt; [a]
</span><a href="../../ghc-prim/src/GHC.Types.html#%3A"><span class="hs-glyph hs-var">:</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([Text] -&gt; [Text]) -&gt; IO [Text] -&gt; IO [Text]
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-operator hs-var">`fmap`</span></a></span><span> </span><span class="annot"><span class="annottext">IO [Text]
</span><a href="#local-6989586621679115834"><span class="hs-identifier hs-var">readChunks</span></a></span><span>
</span><span id="line-152"></span><span>    </span><span id="local-6989586621679115830"><span class="annot"><span class="annottext">[Text]
</span><a href="#local-6989586621679115830"><span class="hs-identifier hs-var">ts</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO [Text]
</span><a href="#local-6989586621679115834"><span class="hs-identifier hs-var">readChunks</span></a></span><span>
</span><span id="line-153"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621679115829"><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679115829"><span class="hs-identifier hs-var">hh'</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe SomeException
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Handle__ -&gt; IO (Handle__, Maybe SomeException)
</span><a href="../../base/src/GHC.IO.Handle.Internals.html#hClose_help"><span class="hs-identifier hs-var">hClose_help</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679115861"><span class="hs-identifier hs-var">hh</span></a></span><span>
</span><span id="line-154"></span><span>    </span><span class="annot"><span class="annottext">(Handle__, Text) -&gt; IO (Handle__, Text)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679115829"><span class="hs-identifier hs-var">hh'</span></a></span><span class="hs-special">{</span><span class="annot"><span class="annottext">haType :: HandleType
</span><a href="../../base/src/GHC.IO.Handle.Types.html#haType"><span class="hs-identifier hs-var">haType</span></a></span><span class="hs-glyph">=</span><span class="annot"><span class="annottext">HandleType
</span><a href="../../base/src/GHC.IO.Handle.Types.html#ClosedHandle"><span class="hs-identifier hs-var">ClosedHandle</span></a></span><span class="hs-special">}</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Text] -&gt; Text
</span><a href="Data.Text.html#concat"><span class="hs-identifier hs-var">T.concat</span></a></span><span> </span><span class="annot"><span class="annottext">[Text]
</span><a href="#local-6989586621679115830"><span class="hs-identifier hs-var">ts</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-155"></span><span>
</span><span id="line-156"></span><span class="hs-comment">-- | Use a more efficient buffer size if we're reading in</span><span>
</span><span id="line-157"></span><span class="hs-comment">-- block-buffered mode with the default buffer size.  When we can</span><span>
</span><span id="line-158"></span><span class="hs-comment">-- determine the size of the handle we're reading, set the buffer size</span><span>
</span><span id="line-159"></span><span class="hs-comment">-- to that, so that we can read the entire file in one chunk.</span><span>
</span><span id="line-160"></span><span class="hs-comment">-- Otherwise, use a buffer size of at least 16KB.</span><span>
</span><span id="line-161"></span><span class="annot"><a href="Data.Text.IO.html#chooseGoodBuffering"><span class="hs-identifier hs-type">chooseGoodBuffering</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-162"></span><span id="chooseGoodBuffering"><span class="annot"><span class="annottext">chooseGoodBuffering :: Handle -&gt; IO ()
</span><a href="Data.Text.IO.html#chooseGoodBuffering"><span class="hs-identifier hs-var hs-var">chooseGoodBuffering</span></a></span></span><span> </span><span id="local-6989586621679115826"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679115826"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-163"></span><span>  </span><span id="local-6989586621679115825"><span class="annot"><span class="annottext">BufferMode
</span><a href="#local-6989586621679115825"><span class="hs-identifier hs-var">bufMode</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO BufferMode
</span><a href="../../base/src/GHC.IO.Handle.html#hGetBuffering"><span class="hs-identifier hs-var">hGetBuffering</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679115826"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-164"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">BufferMode
</span><a href="#local-6989586621679115825"><span class="hs-identifier hs-var">bufMode</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-165"></span><span>    </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#BlockBuffering"><span class="hs-identifier hs-type">BlockBuffering</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-166"></span><span>      </span><span id="local-6989586621679115823"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679115823"><span class="hs-identifier hs-var">d</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO Integer -&gt; (IOException -&gt; IO Integer) -&gt; IO Integer
forall e a. Exception e =&gt; IO a -&gt; (e -&gt; IO a) -&gt; IO a
</span><a href="../../base/src/GHC.IO.html#catch"><span class="hs-identifier hs-var">E.catch</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Integer -&gt; Integer -&gt; Integer)
-&gt; IO Integer -&gt; IO Integer -&gt; IO Integer
forall (m :: * -&gt; *) a1 a2 r.
Monad m =&gt;
(a1 -&gt; a2 -&gt; r) -&gt; m a1 -&gt; m a2 -&gt; m r
</span><a href="../../base/src/GHC.Base.html#liftM2"><span class="hs-identifier hs-var">liftM2</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">-</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Handle -&gt; IO Integer
</span><a href="../../base/src/GHC.IO.Handle.html#hFileSize"><span class="hs-identifier hs-var">hFileSize</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679115826"><span class="hs-identifier hs-var">h</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Handle -&gt; IO Integer
</span><a href="../../base/src/GHC.IO.Handle.html#hTell"><span class="hs-identifier hs-var">hTell</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679115826"><span class="hs-identifier hs-var">h</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">((IOException -&gt; IO Integer) -&gt; IO Integer)
-&gt; (IOException -&gt; IO Integer) -&gt; IO Integer
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span class="hs-special">(</span><span id="local-6989586621679115822"><span class="annot"><span class="annottext">IOException
</span><a href="#local-6989586621679115822"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-glyph">::</span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#IOException"><span class="hs-identifier hs-type">IOException</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-167"></span><span>           </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">IOException -&gt; IOErrorType
</span><a href="../../base/src/GHC.IO.Exception.html#ioe_type"><span class="hs-identifier hs-var hs-var">ioe_type</span></a></span><span> </span><span class="annot"><span class="annottext">IOException
</span><a href="#local-6989586621679115822"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="annot"><span class="annottext">IOErrorType -&gt; IOErrorType -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">IOErrorType
</span><a href="../../base/src/GHC.IO.Exception.html#InappropriateType"><span class="hs-identifier hs-var">InappropriateType</span></a></span><span>
</span><span id="line-168"></span><span>           </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Integer -&gt; IO Integer
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">16384</span></span><span> </span><span class="hs-comment">-- faster than the 2KB default</span><span>
</span><span id="line-169"></span><span>           </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">IOException -&gt; IO Integer
forall e a. Exception e =&gt; e -&gt; IO a
</span><a href="../../base/src/GHC.IO.html#throwIO"><span class="hs-identifier hs-var">E.throwIO</span></a></span><span> </span><span class="annot"><span class="annottext">IOException
</span><a href="#local-6989586621679115822"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-170"></span><span>      </span><span class="annot"><span class="annottext">Bool -&gt; IO () -&gt; IO ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679115823"><span class="hs-identifier hs-var">d</span></a></span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Integer -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3E"><span class="hs-operator hs-var">&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; (Integer -&gt; IO ()) -&gt; Integer -&gt; IO ()
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; BufferMode -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.html#hSetBuffering"><span class="hs-identifier hs-var">hSetBuffering</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679115826"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">(BufferMode -&gt; IO ())
-&gt; (Integer -&gt; BufferMode) -&gt; Integer -&gt; IO ()
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Int -&gt; BufferMode
</span><a href="../../base/src/GHC.IO.Handle.Types.html#BlockBuffering"><span class="hs-identifier hs-var">BlockBuffering</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe Int -&gt; BufferMode)
-&gt; (Integer -&gt; Maybe Int) -&gt; Integer -&gt; BufferMode
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Maybe Int
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">(Int -&gt; Maybe Int) -&gt; (Integer -&gt; Int) -&gt; Integer -&gt; Maybe Int
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Integer -&gt; Int
forall a. Num a =&gt; Integer -&gt; a
</span><a href="../../base/src/GHC.Num.html#fromInteger"><span class="hs-identifier hs-var">fromInteger</span></a></span><span> </span><span class="annot"><span class="annottext">(Integer -&gt; IO ()) -&gt; Integer -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679115823"><span class="hs-identifier hs-var">d</span></a></span><span>
</span><span id="line-171"></span><span>    </span><span class="annot"><span class="annottext">BufferMode
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-172"></span><span>
</span><span id="line-173"></span><span class="hs-comment">-- | Read a single line from a handle.</span><span>
</span><span id="line-174"></span><span class="annot"><a href="Data.Text.IO.html#hGetLine"><span class="hs-identifier hs-type">hGetLine</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span>
</span><span id="line-175"></span><span id="hGetLine"><span class="annot"><span class="annottext">hGetLine :: Handle -&gt; IO Text
</span><a href="Data.Text.IO.html#hGetLine"><span class="hs-identifier hs-var hs-var">hGetLine</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([Text] -&gt; Text) -&gt; Handle -&gt; IO Text
forall t. ([Text] -&gt; t) -&gt; Handle -&gt; IO t
</span><a href="Data.Text.Internal.IO.html#hGetLineWith"><span class="hs-identifier hs-var">hGetLineWith</span></a></span><span> </span><span class="annot"><span class="annottext">[Text] -&gt; Text
</span><a href="Data.Text.html#concat"><span class="hs-identifier hs-var">T.concat</span></a></span><span>
</span><span id="line-176"></span><span>
</span><span id="line-177"></span><span class="hs-comment">-- | Write a string to a handle.</span><span>
</span><span id="line-178"></span><span class="annot"><a href="Data.Text.IO.html#hPutStr"><span class="hs-identifier hs-type">hPutStr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-179"></span><span class="hs-comment">-- This function is lifted almost verbatim from GHC.IO.Handle.Text.</span><span>
</span><span id="line-180"></span><span id="hPutStr"><span class="annot"><span class="annottext">hPutStr :: Handle -&gt; Text -&gt; IO ()
</span><a href="Data.Text.IO.html#hPutStr"><span class="hs-identifier hs-var hs-var">hPutStr</span></a></span></span><span> </span><span id="local-6989586621679115820"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679115820"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span id="local-6989586621679115819"><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679115819"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-181"></span><span>  </span><span class="hs-special">(</span><span id="local-6989586621679115818"><span class="annot"><span class="annottext">(BufferMode, Buffer CharBufElem)
</span><a href="#local-6989586621679115818"><span class="hs-identifier hs-var">buffer_mode</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679115817"><span class="annot"><span class="annottext">Newline
</span><a href="#local-6989586621679115817"><span class="hs-identifier hs-var">nl</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span>
</span><span id="line-182"></span><span>       </span><span class="annot"><span class="annottext">FilePath
-&gt; Handle
-&gt; (Handle__ -&gt; IO ((BufferMode, Buffer CharBufElem), Newline))
-&gt; IO ((BufferMode, Buffer CharBufElem), Newline)
forall a. FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO a) -&gt; IO a
</span><a href="../../base/src/GHC.IO.Handle.Internals.html#wantWritableHandle"><span class="hs-identifier hs-var">wantWritableHandle</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hPutStr&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679115820"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO ((BufferMode, Buffer CharBufElem), Newline))
 -&gt; IO ((BufferMode, Buffer CharBufElem), Newline))
-&gt; (Handle__ -&gt; IO ((BufferMode, Buffer CharBufElem), Newline))
-&gt; IO ((BufferMode, Buffer CharBufElem), Newline)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679115816"><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679115816"><span class="hs-identifier hs-var">h_</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-183"></span><span>                     </span><span id="local-6989586621679115815"><span class="annot"><span class="annottext">(BufferMode, Buffer CharBufElem)
</span><a href="#local-6989586621679115815"><span class="hs-identifier hs-var">bmode</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Handle__ -&gt; IO (BufferMode, Buffer CharBufElem)
</span><a href="Data.Text.IO.html#getSpareBuffer"><span class="hs-identifier hs-var">getSpareBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679115816"><span class="hs-identifier hs-var">h_</span></a></span><span>
</span><span id="line-184"></span><span>                     </span><span class="annot"><span class="annottext">((BufferMode, Buffer CharBufElem), Newline)
-&gt; IO ((BufferMode, Buffer CharBufElem), Newline)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(BufferMode, Buffer CharBufElem)
</span><a href="#local-6989586621679115815"><span class="hs-identifier hs-var">bmode</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Handle__ -&gt; Newline
</span><a href="../../base/src/GHC.IO.Handle.Types.html#haOutputNL"><span class="hs-identifier hs-var hs-var">haOutputNL</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679115816"><span class="hs-identifier hs-var">h_</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-185"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679115813"><span class="annot"><span class="annottext">str :: Stream CharBufElem
</span><a href="#local-6989586621679115813"><span class="hs-identifier hs-var hs-var">str</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Text -&gt; Stream CharBufElem
</span><a href="Data.Text.Internal.Fusion.html#stream"><span class="hs-identifier hs-var">stream</span></a></span><span> </span><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679115819"><span class="hs-identifier hs-var">t</span></a></span><span>
</span><span id="line-186"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">(BufferMode, Buffer CharBufElem)
</span><a href="#local-6989586621679115818"><span class="hs-identifier hs-var">buffer_mode</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-187"></span><span>     </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BufferMode
</span><a href="../../base/src/GHC.IO.Handle.Types.html#NoBuffering"><span class="hs-identifier hs-var">NoBuffering</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Buffer CharBufElem
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Stream CharBufElem -&gt; IO ()
</span><a href="Data.Text.IO.html#hPutChars"><span class="hs-identifier hs-var">hPutChars</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679115820"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">Stream CharBufElem
</span><a href="#local-6989586621679115813"><span class="hs-identifier hs-var">str</span></a></span><span>
</span><span id="line-188"></span><span>     </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BufferMode
</span><a href="../../base/src/GHC.IO.Handle.Types.html#LineBuffering"><span class="hs-identifier hs-var">LineBuffering</span></a></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679115809"><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679115809"><span class="hs-identifier hs-var">buf</span></a></span></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Handle
-&gt; Newline -&gt; Buffer CharBufElem -&gt; Stream CharBufElem -&gt; IO ()
</span><a href="Data.Text.IO.html#writeLines"><span class="hs-identifier hs-var">writeLines</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679115820"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">Newline
</span><a href="#local-6989586621679115817"><span class="hs-identifier hs-var">nl</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679115809"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">Stream CharBufElem
</span><a href="#local-6989586621679115813"><span class="hs-identifier hs-var">str</span></a></span><span>
</span><span id="line-189"></span><span>     </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#BlockBuffering"><span class="hs-identifier hs-type">BlockBuffering</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Int
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679115807"><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679115807"><span class="hs-identifier hs-var">buf</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-190"></span><span>         </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Newline
</span><a href="#local-6989586621679115817"><span class="hs-identifier hs-var">nl</span></a></span><span> </span><span class="annot"><span class="annottext">Newline -&gt; Newline -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">Newline
</span><a href="../../base/src/GHC.IO.Handle.Types.html#CRLF"><span class="hs-identifier hs-var">CRLF</span></a></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Buffer CharBufElem -&gt; Stream CharBufElem -&gt; IO ()
</span><a href="Data.Text.IO.html#writeBlocksCRLF"><span class="hs-identifier hs-var">writeBlocksCRLF</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679115820"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679115807"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">Stream CharBufElem
</span><a href="#local-6989586621679115813"><span class="hs-identifier hs-var">str</span></a></span><span>
</span><span id="line-191"></span><span>         </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Buffer CharBufElem -&gt; Stream CharBufElem -&gt; IO ()
</span><a href="Data.Text.IO.html#writeBlocksRaw"><span class="hs-identifier hs-var">writeBlocksRaw</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679115820"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679115807"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">Stream CharBufElem
</span><a href="#local-6989586621679115813"><span class="hs-identifier hs-var">str</span></a></span><span>
</span><span id="line-192"></span><span>
</span><span id="line-193"></span><span class="annot"><a href="Data.Text.IO.html#hPutChars"><span class="hs-identifier hs-type">hPutChars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Internal.Fusion.Types.html#Stream"><span class="hs-identifier hs-type">Stream</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-194"></span><span id="hPutChars"><span class="annot"><span class="annottext">hPutChars :: Handle -&gt; Stream CharBufElem -&gt; IO ()
</span><a href="Data.Text.IO.html#hPutChars"><span class="hs-identifier hs-var hs-var">hPutChars</span></a></span></span><span> </span><span id="local-6989586621679115803"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679115803"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Internal.Fusion.Types.html#Stream"><span class="hs-identifier hs-type">Stream</span></a></span><span> </span><span id="local-6989586621679115801"><span class="annot"><span class="annottext">s -&gt; Step s CharBufElem
</span><a href="#local-6989586621679115801"><span class="hs-identifier hs-var">next0</span></a></span></span><span> </span><span id="local-6989586621679115800"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115800"><span class="hs-identifier hs-var">s0</span></a></span></span><span> </span><span id="local-6989586621679115799"><span class="annot"><span class="annottext">Size
</span><a href="#local-6989586621679115799"><span class="hs-identifier hs-var">_len</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">s -&gt; IO ()
</span><a href="#local-6989586621679115798"><span class="hs-identifier hs-var">loop</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115800"><span class="hs-identifier hs-var">s0</span></a></span><span>
</span><span id="line-195"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-196"></span><span>    </span><span id="local-6989586621679115798"><span class="annot"><span class="annottext">loop :: s -&gt; IO ()
</span><a href="#local-6989586621679115798"><span class="hs-identifier hs-var hs-var">loop</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679115795"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115795"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">s -&gt; Step s CharBufElem
</span><a href="#local-6989586621679115801"><span class="hs-identifier hs-var">next0</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115795"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-197"></span><span>                </span><span class="annot"><span class="annottext">Step s CharBufElem
</span><a href="Data.Text.Internal.Fusion.Types.html#Done"><span class="hs-identifier hs-var">Done</span></a></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-198"></span><span>                </span><span class="annot"><a href="Data.Text.Internal.Fusion.Types.html#Skip"><span class="hs-identifier hs-type">Skip</span></a></span><span> </span><span id="local-6989586621679115792"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115792"><span class="hs-identifier hs-var">s'</span></a></span></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">s -&gt; IO ()
</span><a href="#local-6989586621679115798"><span class="hs-identifier hs-var">loop</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115792"><span class="hs-identifier hs-var">s'</span></a></span><span>
</span><span id="line-199"></span><span>                </span><span class="annot"><a href="Data.Text.Internal.Fusion.Types.html#Yield"><span class="hs-identifier hs-type">Yield</span></a></span><span> </span><span id="local-6989586621679115790"><span class="annot"><span class="annottext">CharBufElem
</span><a href="#local-6989586621679115790"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621679115789"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115789"><span class="hs-identifier hs-var">s'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; CharBufElem -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.Text.html#hPutChar"><span class="hs-identifier hs-var">hPutChar</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679115803"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">CharBufElem
</span><a href="#local-6989586621679115790"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">IO () -&gt; IO () -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">s -&gt; IO ()
</span><a href="#local-6989586621679115798"><span class="hs-identifier hs-var">loop</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115789"><span class="hs-identifier hs-var">s'</span></a></span><span>
</span><span id="line-200"></span><span>
</span><span id="line-201"></span><span class="hs-comment">-- The following functions are largely lifted from GHC.IO.Handle.Text,</span><span>
</span><span id="line-202"></span><span class="hs-comment">-- but adapted to a coinductive stream of data instead of an inductive</span><span>
</span><span id="line-203"></span><span class="hs-comment">-- list.</span><span>
</span><span id="line-204"></span><span class="hs-comment">--</span><span>
</span><span id="line-205"></span><span class="hs-comment">-- We have several variations of more or less the same code for</span><span>
</span><span id="line-206"></span><span class="hs-comment">-- performance reasons.  Splitting the original buffered write</span><span>
</span><span id="line-207"></span><span class="hs-comment">-- function into line- and block-oriented versions gave us a 2.1x</span><span>
</span><span id="line-208"></span><span class="hs-comment">-- performance improvement.  Lifting out the raw/cooked newline</span><span>
</span><span id="line-209"></span><span class="hs-comment">-- handling gave a few more percent on top.</span><span>
</span><span id="line-210"></span><span>
</span><span id="line-211"></span><span class="annot"><a href="Data.Text.IO.html#writeLines"><span class="hs-identifier hs-type">writeLines</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Newline"><span class="hs-identifier hs-type">Newline</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Buffer.html#Buffer"><span class="hs-identifier hs-type">Buffer</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Buffer.html#CharBufElem"><span class="hs-identifier hs-type">CharBufElem</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Internal.Fusion.Types.html#Stream"><span class="hs-identifier hs-type">Stream</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-212"></span><span id="writeLines"><span class="annot"><span class="annottext">writeLines :: Handle
-&gt; Newline -&gt; Buffer CharBufElem -&gt; Stream CharBufElem -&gt; IO ()
</span><a href="Data.Text.IO.html#writeLines"><span class="hs-identifier hs-var hs-var">writeLines</span></a></span></span><span> </span><span id="local-6989586621679115788"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679115788"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span id="local-6989586621679115787"><span class="annot"><span class="annottext">Newline
</span><a href="#local-6989586621679115787"><span class="hs-identifier hs-var">nl</span></a></span></span><span> </span><span id="local-6989586621679115786"><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679115786"><span class="hs-identifier hs-var">buf0</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Internal.Fusion.Types.html#Stream"><span class="hs-identifier hs-type">Stream</span></a></span><span> </span><span id="local-6989586621679115785"><span class="annot"><span class="annottext">s -&gt; Step s CharBufElem
</span><a href="#local-6989586621679115785"><span class="hs-identifier hs-var">next0</span></a></span></span><span> </span><span id="local-6989586621679115784"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115784"><span class="hs-identifier hs-var">s0</span></a></span></span><span> </span><span id="local-6989586621679115783"><span class="annot"><span class="annottext">Size
</span><a href="#local-6989586621679115783"><span class="hs-identifier hs-var">_len</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">s -&gt; Buffer CharBufElem -&gt; IO ()
</span><a href="#local-6989586621679115782"><span class="hs-identifier hs-var">outer</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115784"><span class="hs-identifier hs-var">s0</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679115786"><span class="hs-identifier hs-var">buf0</span></a></span><span>
</span><span id="line-213"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-214"></span><span>  </span><span id="local-6989586621679115782"><span class="annot"><span class="annottext">outer :: s -&gt; Buffer CharBufElem -&gt; IO ()
</span><a href="#local-6989586621679115782"><span class="hs-identifier hs-var hs-var">outer</span></a></span></span><span> </span><span id="local-6989586621679115781"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115781"><span class="hs-identifier hs-var">s1</span></a></span></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Buffer.html#Buffer"><span class="hs-identifier hs-type">Buffer</span></a></span><span class="hs-special">{</span><span class="annot"><span class="annottext">bufRaw :: forall e. Buffer e -&gt; RawBuffer e
</span><a href="../../base/src/GHC.IO.Buffer.html#bufRaw"><span class="hs-identifier hs-var">bufRaw</span></a></span><span class="hs-glyph">=</span><span id="local-6989586621679115778"><span class="annot"><span class="annottext">RawBuffer CharBufElem
</span><a href="#local-6989586621679115778"><span class="hs-identifier hs-var">raw</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">bufSize :: forall e. Buffer e -&gt; Int
</span><a href="../../base/src/GHC.IO.Buffer.html#bufSize"><span class="hs-identifier hs-var">bufSize</span></a></span><span class="hs-glyph">=</span><span id="local-6989586621679115776"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115776"><span class="hs-identifier hs-var">len</span></a></span></span><span class="hs-special">}</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">s -&gt; Int -&gt; IO ()
</span><a href="#local-6989586621679115775"><span class="hs-identifier hs-var">inner</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115781"><span class="hs-identifier hs-var">s1</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-glyph">::</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-215"></span><span>   </span><span class="hs-keyword">where</span><span>
</span><span id="line-216"></span><span>    </span><span id="local-6989586621679115775"><span class="annot"><span class="annottext">inner :: s -&gt; Int -&gt; IO ()
</span><a href="#local-6989586621679115775"><span class="hs-identifier hs-var hs-var">inner</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679115760"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115760"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679115759"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115759"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-217"></span><span>      </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">s -&gt; Step s CharBufElem
</span><a href="#local-6989586621679115785"><span class="hs-identifier hs-var">next0</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115760"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-218"></span><span>        </span><span class="annot"><span class="annottext">Step s CharBufElem
</span><a href="Data.Text.Internal.Fusion.Types.html#Done"><span class="hs-identifier hs-var">Done</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Bool -&gt; Bool -&gt; IO (Buffer CharBufElem)
</span><a href="#local-6989586621679115758"><span class="hs-identifier hs-var">commit</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115759"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#False"><span class="hs-identifier hs-var">False</span></a></span><span class="hs-comment">{-no flush-}</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#True"><span class="hs-identifier hs-var">True</span></a></span><span class="hs-comment">{-release-}</span><span> </span><span class="annot"><span class="annottext">IO (Buffer CharBufElem) -&gt; IO () -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-219"></span><span>        </span><span class="annot"><a href="Data.Text.Internal.Fusion.Types.html#Skip"><span class="hs-identifier hs-type">Skip</span></a></span><span> </span><span id="local-6989586621679115757"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115757"><span class="hs-identifier hs-var">s'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">s -&gt; Int -&gt; IO ()
</span><a href="#local-6989586621679115775"><span class="hs-identifier hs-var">inner</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115757"><span class="hs-identifier hs-var">s'</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115759"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-220"></span><span>        </span><span class="annot"><a href="Data.Text.Internal.Fusion.Types.html#Yield"><span class="hs-identifier hs-type">Yield</span></a></span><span> </span><span id="local-6989586621679115756"><span class="annot"><span class="annottext">CharBufElem
</span><a href="#local-6989586621679115756"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621679115755"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115755"><span class="hs-identifier hs-var">s'</span></a></span></span><span>
</span><span id="line-221"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115759"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3E%3D"><span class="hs-operator hs-var">&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115776"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Bool -&gt; Bool -&gt; IO (Buffer CharBufElem)
</span><a href="#local-6989586621679115758"><span class="hs-identifier hs-var">commit</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115759"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#True"><span class="hs-identifier hs-var">True</span></a></span><span class="hs-comment">{-needs flush-}</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#False"><span class="hs-identifier hs-var">False</span></a></span><span> </span><span class="annot"><span class="annottext">IO (Buffer CharBufElem) -&gt; (Buffer CharBufElem -&gt; IO ()) -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">s -&gt; Buffer CharBufElem -&gt; IO ()
</span><a href="#local-6989586621679115782"><span class="hs-identifier hs-var">outer</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115760"><span class="hs-identifier hs-var">s</span></a></span><span>
</span><span id="line-222"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CharBufElem
</span><a href="#local-6989586621679115756"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">CharBufElem -&gt; CharBufElem -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">CharBufElem
</span><span class="hs-char">'\n'</span></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-223"></span><span>                   </span><span id="local-6989586621679115753"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115753"><span class="hs-identifier hs-var">n'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Newline
</span><a href="#local-6989586621679115787"><span class="hs-identifier hs-var">nl</span></a></span><span> </span><span class="annot"><span class="annottext">Newline -&gt; Newline -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">Newline
</span><a href="../../base/src/GHC.IO.Handle.Types.html#CRLF"><span class="hs-identifier hs-var">CRLF</span></a></span><span>
</span><span id="line-224"></span><span>                         </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621679115752"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115752"><span class="hs-identifier hs-var">n1</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RawBuffer CharBufElem -&gt; Int -&gt; CharBufElem -&gt; IO Int
</span><a href="../../base/src/GHC.IO.Buffer.html#writeCharBuf"><span class="hs-identifier hs-var">writeCharBuf</span></a></span><span> </span><span class="annot"><span class="annottext">RawBuffer CharBufElem
</span><a href="#local-6989586621679115778"><span class="hs-identifier hs-var">raw</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115759"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">CharBufElem
</span><span class="hs-char">'\r'</span></span><span>
</span><span id="line-225"></span><span>                                 </span><span class="annot"><span class="annottext">RawBuffer CharBufElem -&gt; Int -&gt; CharBufElem -&gt; IO Int
</span><a href="../../base/src/GHC.IO.Buffer.html#writeCharBuf"><span class="hs-identifier hs-var">writeCharBuf</span></a></span><span> </span><span class="annot"><span class="annottext">RawBuffer CharBufElem
</span><a href="#local-6989586621679115778"><span class="hs-identifier hs-var">raw</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115752"><span class="hs-identifier hs-var">n1</span></a></span><span> </span><span class="annot"><span class="annottext">CharBufElem
</span><span class="hs-char">'\n'</span></span><span>
</span><span id="line-226"></span><span>                         </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">RawBuffer CharBufElem -&gt; Int -&gt; CharBufElem -&gt; IO Int
</span><a href="../../base/src/GHC.IO.Buffer.html#writeCharBuf"><span class="hs-identifier hs-var">writeCharBuf</span></a></span><span> </span><span class="annot"><span class="annottext">RawBuffer CharBufElem
</span><a href="#local-6989586621679115778"><span class="hs-identifier hs-var">raw</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115759"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">CharBufElem
</span><a href="#local-6989586621679115756"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-227"></span><span>                   </span><span class="annot"><span class="annottext">Int -&gt; Bool -&gt; Bool -&gt; IO (Buffer CharBufElem)
</span><a href="#local-6989586621679115758"><span class="hs-identifier hs-var">commit</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115753"><span class="hs-identifier hs-var">n'</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#True"><span class="hs-identifier hs-var">True</span></a></span><span class="hs-comment">{-needs flush-}</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#False"><span class="hs-identifier hs-var">False</span></a></span><span> </span><span class="annot"><span class="annottext">IO (Buffer CharBufElem) -&gt; (Buffer CharBufElem -&gt; IO ()) -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">s -&gt; Buffer CharBufElem -&gt; IO ()
</span><a href="#local-6989586621679115782"><span class="hs-identifier hs-var">outer</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115755"><span class="hs-identifier hs-var">s'</span></a></span><span>
</span><span id="line-228"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">RawBuffer CharBufElem -&gt; Int -&gt; CharBufElem -&gt; IO Int
</span><a href="../../base/src/GHC.IO.Buffer.html#writeCharBuf"><span class="hs-identifier hs-var">writeCharBuf</span></a></span><span> </span><span class="annot"><span class="annottext">RawBuffer CharBufElem
</span><a href="#local-6989586621679115778"><span class="hs-identifier hs-var">raw</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115759"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">CharBufElem
</span><a href="#local-6989586621679115756"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">IO Int -&gt; (Int -&gt; IO ()) -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">s -&gt; Int -&gt; IO ()
</span><a href="#local-6989586621679115775"><span class="hs-identifier hs-var">inner</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115755"><span class="hs-identifier hs-var">s'</span></a></span><span>
</span><span id="line-229"></span><span>    </span><span id="local-6989586621679115758"><span class="annot"><span class="annottext">commit :: Int -&gt; Bool -&gt; Bool -&gt; IO (Buffer CharBufElem)
</span><a href="#local-6989586621679115758"><span class="hs-identifier hs-var hs-var">commit</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Handle
-&gt; RawBuffer CharBufElem
-&gt; Int
-&gt; Int
-&gt; Bool
-&gt; Bool
-&gt; IO (Buffer CharBufElem)
</span><a href="Data.Text.IO.html#commitBuffer"><span class="hs-identifier hs-var">commitBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679115788"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">RawBuffer CharBufElem
</span><a href="#local-6989586621679115778"><span class="hs-identifier hs-var">raw</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115776"><span class="hs-identifier hs-var">len</span></a></span><span>
</span><span id="line-230"></span><span>
</span><span id="line-231"></span><span class="annot"><a href="Data.Text.IO.html#writeBlocksCRLF"><span class="hs-identifier hs-type">writeBlocksCRLF</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Buffer.html#Buffer"><span class="hs-identifier hs-type">Buffer</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Buffer.html#CharBufElem"><span class="hs-identifier hs-type">CharBufElem</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Internal.Fusion.Types.html#Stream"><span class="hs-identifier hs-type">Stream</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-232"></span><span id="writeBlocksCRLF"><span class="annot"><span class="annottext">writeBlocksCRLF :: Handle -&gt; Buffer CharBufElem -&gt; Stream CharBufElem -&gt; IO ()
</span><a href="Data.Text.IO.html#writeBlocksCRLF"><span class="hs-identifier hs-var hs-var">writeBlocksCRLF</span></a></span></span><span> </span><span id="local-6989586621679115750"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679115750"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span id="local-6989586621679115749"><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679115749"><span class="hs-identifier hs-var">buf0</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Internal.Fusion.Types.html#Stream"><span class="hs-identifier hs-type">Stream</span></a></span><span> </span><span id="local-6989586621679115748"><span class="annot"><span class="annottext">s -&gt; Step s CharBufElem
</span><a href="#local-6989586621679115748"><span class="hs-identifier hs-var">next0</span></a></span></span><span> </span><span id="local-6989586621679115747"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115747"><span class="hs-identifier hs-var">s0</span></a></span></span><span> </span><span id="local-6989586621679115746"><span class="annot"><span class="annottext">Size
</span><a href="#local-6989586621679115746"><span class="hs-identifier hs-var">_len</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">s -&gt; Buffer CharBufElem -&gt; IO ()
</span><a href="#local-6989586621679115745"><span class="hs-identifier hs-var">outer</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115747"><span class="hs-identifier hs-var">s0</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679115749"><span class="hs-identifier hs-var">buf0</span></a></span><span>
</span><span id="line-233"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-234"></span><span>  </span><span id="local-6989586621679115745"><span class="annot"><span class="annottext">outer :: s -&gt; Buffer CharBufElem -&gt; IO ()
</span><a href="#local-6989586621679115745"><span class="hs-identifier hs-var hs-var">outer</span></a></span></span><span> </span><span id="local-6989586621679115744"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115744"><span class="hs-identifier hs-var">s1</span></a></span></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Buffer.html#Buffer"><span class="hs-identifier hs-type">Buffer</span></a></span><span class="hs-special">{</span><span class="annot"><span class="annottext">bufRaw :: forall e. Buffer e -&gt; RawBuffer e
</span><a href="../../base/src/GHC.IO.Buffer.html#bufRaw"><span class="hs-identifier hs-var">bufRaw</span></a></span><span class="hs-glyph">=</span><span id="local-6989586621679115743"><span class="annot"><span class="annottext">RawBuffer CharBufElem
</span><a href="#local-6989586621679115743"><span class="hs-identifier hs-var">raw</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">bufSize :: forall e. Buffer e -&gt; Int
</span><a href="../../base/src/GHC.IO.Buffer.html#bufSize"><span class="hs-identifier hs-var">bufSize</span></a></span><span class="hs-glyph">=</span><span id="local-6989586621679115742"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115742"><span class="hs-identifier hs-var">len</span></a></span></span><span class="hs-special">}</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">s -&gt; Int -&gt; IO ()
</span><a href="#local-6989586621679115741"><span class="hs-identifier hs-var">inner</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115744"><span class="hs-identifier hs-var">s1</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-glyph">::</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-235"></span><span>   </span><span class="hs-keyword">where</span><span>
</span><span id="line-236"></span><span>    </span><span id="local-6989586621679115741"><span class="annot"><span class="annottext">inner :: s -&gt; Int -&gt; IO ()
</span><a href="#local-6989586621679115741"><span class="hs-identifier hs-var hs-var">inner</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679115730"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115730"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679115729"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115729"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-237"></span><span>      </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">s -&gt; Step s CharBufElem
</span><a href="#local-6989586621679115748"><span class="hs-identifier hs-var">next0</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115730"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-238"></span><span>        </span><span class="annot"><span class="annottext">Step s CharBufElem
</span><a href="Data.Text.Internal.Fusion.Types.html#Done"><span class="hs-identifier hs-var">Done</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Bool -&gt; Bool -&gt; IO (Buffer CharBufElem)
</span><a href="#local-6989586621679115728"><span class="hs-identifier hs-var">commit</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115729"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#False"><span class="hs-identifier hs-var">False</span></a></span><span class="hs-comment">{-no flush-}</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#True"><span class="hs-identifier hs-var">True</span></a></span><span class="hs-comment">{-release-}</span><span> </span><span class="annot"><span class="annottext">IO (Buffer CharBufElem) -&gt; IO () -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-239"></span><span>        </span><span class="annot"><a href="Data.Text.Internal.Fusion.Types.html#Skip"><span class="hs-identifier hs-type">Skip</span></a></span><span> </span><span id="local-6989586621679115727"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115727"><span class="hs-identifier hs-var">s'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">s -&gt; Int -&gt; IO ()
</span><a href="#local-6989586621679115741"><span class="hs-identifier hs-var">inner</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115727"><span class="hs-identifier hs-var">s'</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115729"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-240"></span><span>        </span><span class="annot"><a href="Data.Text.Internal.Fusion.Types.html#Yield"><span class="hs-identifier hs-type">Yield</span></a></span><span> </span><span id="local-6989586621679115726"><span class="annot"><span class="annottext">CharBufElem
</span><a href="#local-6989586621679115726"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621679115725"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115725"><span class="hs-identifier hs-var">s'</span></a></span></span><span>
</span><span id="line-241"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115729"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3E%3D"><span class="hs-operator hs-var">&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115742"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Bool -&gt; Bool -&gt; IO (Buffer CharBufElem)
</span><a href="#local-6989586621679115728"><span class="hs-identifier hs-var">commit</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115729"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#True"><span class="hs-identifier hs-var">True</span></a></span><span class="hs-comment">{-needs flush-}</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#False"><span class="hs-identifier hs-var">False</span></a></span><span> </span><span class="annot"><span class="annottext">IO (Buffer CharBufElem) -&gt; (Buffer CharBufElem -&gt; IO ()) -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">s -&gt; Buffer CharBufElem -&gt; IO ()
</span><a href="#local-6989586621679115745"><span class="hs-identifier hs-var">outer</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115730"><span class="hs-identifier hs-var">s</span></a></span><span>
</span><span id="line-242"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CharBufElem
</span><a href="#local-6989586621679115726"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">CharBufElem -&gt; CharBufElem -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">CharBufElem
</span><span class="hs-char">'\n'</span></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621679115724"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115724"><span class="hs-identifier hs-var">n1</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RawBuffer CharBufElem -&gt; Int -&gt; CharBufElem -&gt; IO Int
</span><a href="../../base/src/GHC.IO.Buffer.html#writeCharBuf"><span class="hs-identifier hs-var">writeCharBuf</span></a></span><span> </span><span class="annot"><span class="annottext">RawBuffer CharBufElem
</span><a href="#local-6989586621679115743"><span class="hs-identifier hs-var">raw</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115729"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">CharBufElem
</span><span class="hs-char">'\r'</span></span><span>
</span><span id="line-243"></span><span>                               </span><span class="annot"><span class="annottext">RawBuffer CharBufElem -&gt; Int -&gt; CharBufElem -&gt; IO Int
</span><a href="../../base/src/GHC.IO.Buffer.html#writeCharBuf"><span class="hs-identifier hs-var">writeCharBuf</span></a></span><span> </span><span class="annot"><span class="annottext">RawBuffer CharBufElem
</span><a href="#local-6989586621679115743"><span class="hs-identifier hs-var">raw</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115724"><span class="hs-identifier hs-var">n1</span></a></span><span> </span><span class="annot"><span class="annottext">CharBufElem
</span><span class="hs-char">'\n'</span></span><span> </span><span class="annot"><span class="annottext">IO Int -&gt; (Int -&gt; IO ()) -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">s -&gt; Int -&gt; IO ()
</span><a href="#local-6989586621679115741"><span class="hs-identifier hs-var">inner</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115725"><span class="hs-identifier hs-var">s'</span></a></span><span>
</span><span id="line-244"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">RawBuffer CharBufElem -&gt; Int -&gt; CharBufElem -&gt; IO Int
</span><a href="../../base/src/GHC.IO.Buffer.html#writeCharBuf"><span class="hs-identifier hs-var">writeCharBuf</span></a></span><span> </span><span class="annot"><span class="annottext">RawBuffer CharBufElem
</span><a href="#local-6989586621679115743"><span class="hs-identifier hs-var">raw</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115729"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">CharBufElem
</span><a href="#local-6989586621679115726"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">IO Int -&gt; (Int -&gt; IO ()) -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">s -&gt; Int -&gt; IO ()
</span><a href="#local-6989586621679115741"><span class="hs-identifier hs-var">inner</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115725"><span class="hs-identifier hs-var">s'</span></a></span><span>
</span><span id="line-245"></span><span>    </span><span id="local-6989586621679115728"><span class="annot"><span class="annottext">commit :: Int -&gt; Bool -&gt; Bool -&gt; IO (Buffer CharBufElem)
</span><a href="#local-6989586621679115728"><span class="hs-identifier hs-var hs-var">commit</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Handle
-&gt; RawBuffer CharBufElem
-&gt; Int
-&gt; Int
-&gt; Bool
-&gt; Bool
-&gt; IO (Buffer CharBufElem)
</span><a href="Data.Text.IO.html#commitBuffer"><span class="hs-identifier hs-var">commitBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679115750"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">RawBuffer CharBufElem
</span><a href="#local-6989586621679115743"><span class="hs-identifier hs-var">raw</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115742"><span class="hs-identifier hs-var">len</span></a></span><span>
</span><span id="line-246"></span><span>
</span><span id="line-247"></span><span class="annot"><a href="Data.Text.IO.html#writeBlocksRaw"><span class="hs-identifier hs-type">writeBlocksRaw</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Buffer.html#Buffer"><span class="hs-identifier hs-type">Buffer</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Buffer.html#CharBufElem"><span class="hs-identifier hs-type">CharBufElem</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Internal.Fusion.Types.html#Stream"><span class="hs-identifier hs-type">Stream</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-248"></span><span id="writeBlocksRaw"><span class="annot"><span class="annottext">writeBlocksRaw :: Handle -&gt; Buffer CharBufElem -&gt; Stream CharBufElem -&gt; IO ()
</span><a href="Data.Text.IO.html#writeBlocksRaw"><span class="hs-identifier hs-var hs-var">writeBlocksRaw</span></a></span></span><span> </span><span id="local-6989586621679115723"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679115723"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span id="local-6989586621679115722"><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679115722"><span class="hs-identifier hs-var">buf0</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Internal.Fusion.Types.html#Stream"><span class="hs-identifier hs-type">Stream</span></a></span><span> </span><span id="local-6989586621679115721"><span class="annot"><span class="annottext">s -&gt; Step s CharBufElem
</span><a href="#local-6989586621679115721"><span class="hs-identifier hs-var">next0</span></a></span></span><span> </span><span id="local-6989586621679115720"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115720"><span class="hs-identifier hs-var">s0</span></a></span></span><span> </span><span id="local-6989586621679115719"><span class="annot"><span class="annottext">Size
</span><a href="#local-6989586621679115719"><span class="hs-identifier hs-var">_len</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">s -&gt; Buffer CharBufElem -&gt; IO ()
</span><a href="#local-6989586621679115718"><span class="hs-identifier hs-var">outer</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115720"><span class="hs-identifier hs-var">s0</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679115722"><span class="hs-identifier hs-var">buf0</span></a></span><span>
</span><span id="line-249"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-250"></span><span>  </span><span id="local-6989586621679115718"><span class="annot"><span class="annottext">outer :: s -&gt; Buffer CharBufElem -&gt; IO ()
</span><a href="#local-6989586621679115718"><span class="hs-identifier hs-var hs-var">outer</span></a></span></span><span> </span><span id="local-6989586621679115717"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115717"><span class="hs-identifier hs-var">s1</span></a></span></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Buffer.html#Buffer"><span class="hs-identifier hs-type">Buffer</span></a></span><span class="hs-special">{</span><span class="annot"><span class="annottext">bufRaw :: forall e. Buffer e -&gt; RawBuffer e
</span><a href="../../base/src/GHC.IO.Buffer.html#bufRaw"><span class="hs-identifier hs-var">bufRaw</span></a></span><span class="hs-glyph">=</span><span id="local-6989586621679115716"><span class="annot"><span class="annottext">RawBuffer CharBufElem
</span><a href="#local-6989586621679115716"><span class="hs-identifier hs-var">raw</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">bufSize :: forall e. Buffer e -&gt; Int
</span><a href="../../base/src/GHC.IO.Buffer.html#bufSize"><span class="hs-identifier hs-var">bufSize</span></a></span><span class="hs-glyph">=</span><span id="local-6989586621679115715"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115715"><span class="hs-identifier hs-var">len</span></a></span></span><span class="hs-special">}</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">s -&gt; Int -&gt; IO ()
</span><a href="#local-6989586621679115714"><span class="hs-identifier hs-var">inner</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115717"><span class="hs-identifier hs-var">s1</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-glyph">::</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-251"></span><span>   </span><span class="hs-keyword">where</span><span>
</span><span id="line-252"></span><span>    </span><span id="local-6989586621679115714"><span class="annot"><span class="annottext">inner :: s -&gt; Int -&gt; IO ()
</span><a href="#local-6989586621679115714"><span class="hs-identifier hs-var hs-var">inner</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679115706"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115706"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679115705"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115705"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-253"></span><span>      </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">s -&gt; Step s CharBufElem
</span><a href="#local-6989586621679115721"><span class="hs-identifier hs-var">next0</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115706"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-254"></span><span>        </span><span class="annot"><span class="annottext">Step s CharBufElem
</span><a href="Data.Text.Internal.Fusion.Types.html#Done"><span class="hs-identifier hs-var">Done</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Bool -&gt; Bool -&gt; IO (Buffer CharBufElem)
</span><a href="#local-6989586621679115704"><span class="hs-identifier hs-var">commit</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115705"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#False"><span class="hs-identifier hs-var">False</span></a></span><span class="hs-comment">{-no flush-}</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#True"><span class="hs-identifier hs-var">True</span></a></span><span class="hs-comment">{-release-}</span><span> </span><span class="annot"><span class="annottext">IO (Buffer CharBufElem) -&gt; IO () -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-255"></span><span>        </span><span class="annot"><a href="Data.Text.Internal.Fusion.Types.html#Skip"><span class="hs-identifier hs-type">Skip</span></a></span><span> </span><span id="local-6989586621679115703"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115703"><span class="hs-identifier hs-var">s'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">s -&gt; Int -&gt; IO ()
</span><a href="#local-6989586621679115714"><span class="hs-identifier hs-var">inner</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115703"><span class="hs-identifier hs-var">s'</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115705"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-256"></span><span>        </span><span class="annot"><a href="Data.Text.Internal.Fusion.Types.html#Yield"><span class="hs-identifier hs-type">Yield</span></a></span><span> </span><span id="local-6989586621679115702"><span class="annot"><span class="annottext">CharBufElem
</span><a href="#local-6989586621679115702"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621679115701"><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115701"><span class="hs-identifier hs-var">s'</span></a></span></span><span>
</span><span id="line-257"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115705"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3E%3D"><span class="hs-operator hs-var">&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115715"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Bool -&gt; Bool -&gt; IO (Buffer CharBufElem)
</span><a href="#local-6989586621679115704"><span class="hs-identifier hs-var">commit</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115705"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#True"><span class="hs-identifier hs-var">True</span></a></span><span class="hs-comment">{-needs flush-}</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#False"><span class="hs-identifier hs-var">False</span></a></span><span> </span><span class="annot"><span class="annottext">IO (Buffer CharBufElem) -&gt; (Buffer CharBufElem -&gt; IO ()) -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">s -&gt; Buffer CharBufElem -&gt; IO ()
</span><a href="#local-6989586621679115718"><span class="hs-identifier hs-var">outer</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115706"><span class="hs-identifier hs-var">s</span></a></span><span>
</span><span id="line-258"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">RawBuffer CharBufElem -&gt; Int -&gt; CharBufElem -&gt; IO Int
</span><a href="../../base/src/GHC.IO.Buffer.html#writeCharBuf"><span class="hs-identifier hs-var">writeCharBuf</span></a></span><span> </span><span class="annot"><span class="annottext">RawBuffer CharBufElem
</span><a href="#local-6989586621679115716"><span class="hs-identifier hs-var">raw</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115705"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">CharBufElem
</span><a href="#local-6989586621679115702"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">IO Int -&gt; (Int -&gt; IO ()) -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">s -&gt; Int -&gt; IO ()
</span><a href="#local-6989586621679115714"><span class="hs-identifier hs-var">inner</span></a></span><span> </span><span class="annot"><span class="annottext">s
</span><a href="#local-6989586621679115701"><span class="hs-identifier hs-var">s'</span></a></span><span>
</span><span id="line-259"></span><span>    </span><span id="local-6989586621679115704"><span class="annot"><span class="annottext">commit :: Int -&gt; Bool -&gt; Bool -&gt; IO (Buffer CharBufElem)
</span><a href="#local-6989586621679115704"><span class="hs-identifier hs-var hs-var">commit</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Handle
-&gt; RawBuffer CharBufElem
-&gt; Int
-&gt; Int
-&gt; Bool
-&gt; Bool
-&gt; IO (Buffer CharBufElem)
</span><a href="Data.Text.IO.html#commitBuffer"><span class="hs-identifier hs-var">commitBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679115723"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">RawBuffer CharBufElem
</span><a href="#local-6989586621679115716"><span class="hs-identifier hs-var">raw</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115715"><span class="hs-identifier hs-var">len</span></a></span><span>
</span><span id="line-260"></span><span>
</span><span id="line-261"></span><span class="hs-comment">-- This function is completely lifted from GHC.IO.Handle.Text.</span><span>
</span><span id="line-262"></span><span class="annot"><a href="Data.Text.IO.html#getSpareBuffer"><span class="hs-identifier hs-type">getSpareBuffer</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#BufferMode"><span class="hs-identifier hs-type">BufferMode</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Buffer.html#CharBuffer"><span class="hs-identifier hs-type">CharBuffer</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-263"></span><span id="getSpareBuffer"><span class="annot"><span class="annottext">getSpareBuffer :: Handle__ -&gt; IO (BufferMode, Buffer CharBufElem)
</span><a href="Data.Text.IO.html#getSpareBuffer"><span class="hs-identifier hs-var hs-var">getSpareBuffer</span></a></span></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">{</span><span class="annot"><span class="annottext">haCharBuffer :: Handle__ -&gt; IORef (Buffer CharBufElem)
</span><a href="../../base/src/GHC.IO.Handle.Types.html#haCharBuffer"><span class="hs-identifier hs-var">haCharBuffer</span></a></span><span class="hs-glyph">=</span><span id="local-6989586621679115687"><span class="annot"><span class="annottext">IORef (Buffer CharBufElem)
</span><a href="#local-6989586621679115687"><span class="hs-identifier hs-var">ref</span></a></span></span><span class="hs-special">,</span><span>
</span><span id="line-264"></span><span>                        </span><span class="annot"><span class="annottext">haBuffers :: Handle__ -&gt; IORef (BufferList CharBufElem)
</span><a href="../../base/src/GHC.IO.Handle.Types.html#haBuffers"><span class="hs-identifier hs-var">haBuffers</span></a></span><span class="hs-glyph">=</span><span id="local-6989586621679115686"><span class="annot"><span class="annottext">IORef (BufferList CharBufElem)
</span><a href="#local-6989586621679115686"><span class="hs-identifier hs-var">spare_ref</span></a></span></span><span class="hs-special">,</span><span>
</span><span id="line-265"></span><span>                        </span><span class="annot"><span class="annottext">haBufferMode :: Handle__ -&gt; BufferMode
</span><a href="../../base/src/GHC.IO.Handle.Types.html#haBufferMode"><span class="hs-identifier hs-var">haBufferMode</span></a></span><span class="hs-glyph">=</span><span id="local-6989586621679115685"><span class="annot"><span class="annottext">BufferMode
</span><a href="#local-6989586621679115685"><span class="hs-identifier hs-var">mode</span></a></span></span><span class="hs-special">}</span><span>
</span><span id="line-266"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-267"></span><span>   </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">BufferMode
</span><a href="#local-6989586621679115685"><span class="hs-identifier hs-var">mode</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-268"></span><span>     </span><span class="annot"><span class="annottext">BufferMode
</span><a href="../../base/src/GHC.IO.Handle.Types.html#NoBuffering"><span class="hs-identifier hs-var">NoBuffering</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(BufferMode, Buffer CharBufElem)
-&gt; IO (BufferMode, Buffer CharBufElem)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BufferMode
</span><a href="#local-6989586621679115685"><span class="hs-identifier hs-var">mode</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; Buffer CharBufElem
forall a. HasCallStack =&gt; FilePath -&gt; a
</span><a href="../../base/src/GHC.Err.html#error"><span class="hs-identifier hs-var">error</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;no buffer!&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-269"></span><span>     </span><span class="annot"><span class="annottext">BufferMode
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-270"></span><span>          </span><span id="local-6989586621679115683"><span class="annot"><span class="annottext">BufferList CharBufElem
</span><a href="#local-6989586621679115683"><span class="hs-identifier hs-var">bufs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (BufferList CharBufElem) -&gt; IO (BufferList CharBufElem)
forall a. IORef a -&gt; IO a
</span><a href="../../base/src/GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (BufferList CharBufElem)
</span><a href="#local-6989586621679115686"><span class="hs-identifier hs-var">spare_ref</span></a></span><span>
</span><span id="line-271"></span><span>          </span><span id="local-6989586621679115682"><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679115682"><span class="hs-identifier hs-var">buf</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (Buffer CharBufElem) -&gt; IO (Buffer CharBufElem)
forall a. IORef a -&gt; IO a
</span><a href="../../base/src/GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (Buffer CharBufElem)
</span><a href="#local-6989586621679115687"><span class="hs-identifier hs-var">ref</span></a></span><span>
</span><span id="line-272"></span><span>          </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">BufferList CharBufElem
</span><a href="#local-6989586621679115683"><span class="hs-identifier hs-var">bufs</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-273"></span><span>            </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#BufferListCons"><span class="hs-identifier hs-type">BufferListCons</span></a></span><span> </span><span id="local-6989586621679115680"><span class="annot"><span class="annottext">RawBuffer CharBufElem
</span><a href="#local-6989586621679115680"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span id="local-6989586621679115679"><span class="annot"><span class="annottext">BufferList CharBufElem
</span><a href="#local-6989586621679115679"><span class="hs-identifier hs-var">rest</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-274"></span><span>                </span><span class="annot"><span class="annottext">IORef (BufferList CharBufElem) -&gt; BufferList CharBufElem -&gt; IO ()
forall a. IORef a -&gt; a -&gt; IO ()
</span><a href="../../base/src/GHC.IORef.html#writeIORef"><span class="hs-identifier hs-var">writeIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (BufferList CharBufElem)
</span><a href="#local-6989586621679115686"><span class="hs-identifier hs-var">spare_ref</span></a></span><span> </span><span class="annot"><span class="annottext">BufferList CharBufElem
</span><a href="#local-6989586621679115679"><span class="hs-identifier hs-var">rest</span></a></span><span>
</span><span id="line-275"></span><span>                </span><span class="annot"><span class="annottext">(BufferMode, Buffer CharBufElem)
-&gt; IO (BufferMode, Buffer CharBufElem)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">BufferMode
</span><a href="#local-6989586621679115685"><span class="hs-identifier hs-var">mode</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">RawBuffer CharBufElem -&gt; Int -&gt; BufferState -&gt; Buffer CharBufElem
forall e. RawBuffer e -&gt; Int -&gt; BufferState -&gt; Buffer e
</span><a href="../../base/src/GHC.IO.Buffer.html#emptyBuffer"><span class="hs-identifier hs-var">emptyBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">RawBuffer CharBufElem
</span><a href="#local-6989586621679115680"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Buffer CharBufElem -&gt; Int
forall e. Buffer e -&gt; Int
</span><a href="../../base/src/GHC.IO.Buffer.html#bufSize"><span class="hs-identifier hs-var hs-var">bufSize</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679115682"><span class="hs-identifier hs-var">buf</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">BufferState
</span><a href="../../base/src/GHC.IO.Buffer.html#WriteBuffer"><span class="hs-identifier hs-var">WriteBuffer</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-276"></span><span>            </span><span class="annot"><span class="annottext">BufferList CharBufElem
</span><a href="../../base/src/GHC.IO.Handle.Types.html#BufferListNil"><span class="hs-identifier hs-var">BufferListNil</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-277"></span><span>                </span><span id="local-6989586621679115676"><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679115676"><span class="hs-identifier hs-var">new_buf</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; BufferState -&gt; IO (Buffer CharBufElem)
</span><a href="../../base/src/GHC.IO.Buffer.html#newCharBuffer"><span class="hs-identifier hs-var">newCharBuffer</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Buffer CharBufElem -&gt; Int
forall e. Buffer e -&gt; Int
</span><a href="../../base/src/GHC.IO.Buffer.html#bufSize"><span class="hs-identifier hs-var hs-var">bufSize</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679115682"><span class="hs-identifier hs-var">buf</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">BufferState
</span><a href="../../base/src/GHC.IO.Buffer.html#WriteBuffer"><span class="hs-identifier hs-var">WriteBuffer</span></a></span><span>
</span><span id="line-278"></span><span>                </span><span class="annot"><span class="annottext">(BufferMode, Buffer CharBufElem)
-&gt; IO (BufferMode, Buffer CharBufElem)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BufferMode
</span><a href="#local-6989586621679115685"><span class="hs-identifier hs-var">mode</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679115676"><span class="hs-identifier hs-var">new_buf</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-279"></span><span>
</span><span id="line-280"></span><span>
</span><span id="line-281"></span><span class="hs-comment">-- This function is completely lifted from GHC.IO.Handle.Text.</span><span>
</span><span id="line-282"></span><span class="annot"><a href="Data.Text.IO.html#commitBuffer"><span class="hs-identifier hs-type">commitBuffer</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Buffer.html#RawCharBuffer"><span class="hs-identifier hs-type">RawCharBuffer</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>
</span><span id="line-283"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Buffer.html#CharBuffer"><span class="hs-identifier hs-type">CharBuffer</span></a></span><span>
</span><span id="line-284"></span><span id="commitBuffer"><span class="annot"><span class="annottext">commitBuffer :: Handle
-&gt; RawBuffer CharBufElem
-&gt; Int
-&gt; Int
-&gt; Bool
-&gt; Bool
-&gt; IO (Buffer CharBufElem)
</span><a href="Data.Text.IO.html#commitBuffer"><span class="hs-identifier hs-var hs-var">commitBuffer</span></a></span></span><span> </span><span id="local-6989586621679115675"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679115675"><span class="hs-identifier hs-var">hdl</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679115674"><span class="annot"><span class="annottext">RawBuffer CharBufElem
</span><a href="#local-6989586621679115674"><span class="hs-identifier hs-var">raw</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679115673"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115673"><span class="hs-identifier hs-var">sz</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679115672"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115672"><span class="hs-identifier hs-var">count</span></a></span></span><span> </span><span id="local-6989586621679115671"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679115671"><span class="hs-identifier hs-var">flush</span></a></span></span><span> </span><span id="local-6989586621679115670"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679115670"><span class="hs-identifier hs-var">release</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-285"></span><span>  </span><span class="annot"><span class="annottext">FilePath
-&gt; Handle
-&gt; (Handle__ -&gt; IO (Buffer CharBufElem))
-&gt; IO (Buffer CharBufElem)
forall a. FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO a) -&gt; IO a
</span><a href="../../base/src/GHC.IO.Handle.Internals.html#wantWritableHandle"><span class="hs-identifier hs-var">wantWritableHandle</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;commitAndReleaseBuffer&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679115675"><span class="hs-identifier hs-var">hdl</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO (Buffer CharBufElem)) -&gt; IO (Buffer CharBufElem))
-&gt; (Handle__ -&gt; IO (Buffer CharBufElem)) -&gt; IO (Buffer CharBufElem)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-286"></span><span>     </span><span class="annot"><span class="annottext">RawBuffer CharBufElem
-&gt; Int
-&gt; Int
-&gt; Bool
-&gt; Bool
-&gt; Handle__
-&gt; IO (Buffer CharBufElem)
</span><a href="../../base/src/GHC.IO.Handle.Text.html#commitBuffer%27"><span class="hs-identifier hs-var">commitBuffer'</span></a></span><span> </span><span class="annot"><span class="annottext">RawBuffer CharBufElem
</span><a href="#local-6989586621679115674"><span class="hs-identifier hs-var">raw</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115673"><span class="hs-identifier hs-var">sz</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679115672"><span class="hs-identifier hs-var">count</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679115671"><span class="hs-identifier hs-var">flush</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679115670"><span class="hs-identifier hs-var">release</span></a></span><span>
</span><span id="line-287"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.Text.IO.html#commitBuffer"><span class="hs-pragma hs-type">commitBuffer</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-288"></span><span>
</span><span id="line-289"></span><span class="hs-comment">-- | Write a string to a handle, followed by a newline.</span><span>
</span><span id="line-290"></span><span class="annot"><a href="Data.Text.IO.html#hPutStrLn"><span class="hs-identifier hs-type">hPutStrLn</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-291"></span><span id="hPutStrLn"><span class="annot"><span class="annottext">hPutStrLn :: Handle -&gt; Text -&gt; IO ()
</span><a href="Data.Text.IO.html#hPutStrLn"><span class="hs-identifier hs-var hs-var">hPutStrLn</span></a></span></span><span> </span><span id="local-6989586621679115669"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679115669"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span id="local-6989586621679115668"><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679115668"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Text -&gt; IO ()
</span><a href="Data.Text.IO.html#hPutStr"><span class="hs-identifier hs-var">hPutStr</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679115669"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679115668"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="annot"><span class="annottext">IO () -&gt; IO () -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; CharBufElem -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.Text.html#hPutChar"><span class="hs-identifier hs-var">hPutChar</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679115669"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">CharBufElem
</span><span class="hs-char">'\n'</span></span><span>
</span><span id="line-292"></span><span>
</span><span id="line-293"></span><span class="hs-comment">-- | The 'interact' function takes a function of type @Text -&gt; Text@</span><span>
</span><span id="line-294"></span><span class="hs-comment">-- as its argument. The entire input from the standard input device is</span><span>
</span><span id="line-295"></span><span class="hs-comment">-- passed to this function as its argument, and the resulting string</span><span>
</span><span id="line-296"></span><span class="hs-comment">-- is output on the standard output device.</span><span>
</span><span id="line-297"></span><span class="annot"><a href="Data.Text.IO.html#interact"><span class="hs-identifier hs-type">interact</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-298"></span><span id="interact"><span class="annot"><span class="annottext">interact :: (Text -&gt; Text) -&gt; IO ()
</span><a href="Data.Text.IO.html#interact"><span class="hs-identifier hs-var hs-var">interact</span></a></span></span><span> </span><span id="local-6989586621679115667"><span class="annot"><span class="annottext">Text -&gt; Text
</span><a href="#local-6989586621679115667"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Text -&gt; IO ()
</span><a href="Data.Text.IO.html#putStr"><span class="hs-identifier hs-var">putStr</span></a></span><span> </span><span class="annot"><span class="annottext">(Text -&gt; IO ()) -&gt; (Text -&gt; Text) -&gt; Text -&gt; IO ()
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Text -&gt; Text
</span><a href="#local-6989586621679115667"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">(Text -&gt; IO ()) -&gt; IO Text -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; (a -&gt; m b) -&gt; m a -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3D%3C%3C"><span class="hs-operator hs-var">=&lt;&lt;</span></a></span><span> </span><span class="annot"><span class="annottext">IO Text
</span><a href="Data.Text.IO.html#getContents"><span class="hs-identifier hs-var">getContents</span></a></span><span>
</span><span id="line-299"></span><span>
</span><span id="line-300"></span><span class="hs-comment">-- | Read all user input on 'stdin' as a single string.</span><span>
</span><span id="line-301"></span><span class="annot"><a href="Data.Text.IO.html#getContents"><span class="hs-identifier hs-type">getContents</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span>
</span><span id="line-302"></span><span id="getContents"><span class="annot"><span class="annottext">getContents :: IO Text
</span><a href="Data.Text.IO.html#getContents"><span class="hs-identifier hs-var hs-var">getContents</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO Text
</span><a href="Data.Text.IO.html#hGetContents"><span class="hs-identifier hs-var">hGetContents</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="../../base/src/GHC.IO.StdHandles.html#stdin"><span class="hs-identifier hs-var">stdin</span></a></span><span>
</span><span id="line-303"></span><span>
</span><span id="line-304"></span><span class="hs-comment">-- | Read a single line of user input from 'stdin'.</span><span>
</span><span id="line-305"></span><span class="annot"><a href="Data.Text.IO.html#getLine"><span class="hs-identifier hs-type">getLine</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span>
</span><span id="line-306"></span><span id="getLine"><span class="annot"><span class="annottext">getLine :: IO Text
</span><a href="Data.Text.IO.html#getLine"><span class="hs-identifier hs-var hs-var">getLine</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO Text
</span><a href="Data.Text.IO.html#hGetLine"><span class="hs-identifier hs-var">hGetLine</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="../../base/src/GHC.IO.StdHandles.html#stdin"><span class="hs-identifier hs-var">stdin</span></a></span><span>
</span><span id="line-307"></span><span>
</span><span id="line-308"></span><span class="hs-comment">-- | Write a string to 'stdout'.</span><span>
</span><span id="line-309"></span><span class="annot"><a href="Data.Text.IO.html#putStr"><span class="hs-identifier hs-type">putStr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-310"></span><span id="putStr"><span class="annot"><span class="annottext">putStr :: Text -&gt; IO ()
</span><a href="Data.Text.IO.html#putStr"><span class="hs-identifier hs-var hs-var">putStr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Text -&gt; IO ()
</span><a href="Data.Text.IO.html#hPutStr"><span class="hs-identifier hs-var">hPutStr</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="../../base/src/GHC.IO.StdHandles.html#stdout"><span class="hs-identifier hs-var">stdout</span></a></span><span>
</span><span id="line-311"></span><span>
</span><span id="line-312"></span><span class="hs-comment">-- | Write a string to 'stdout', followed by a newline.</span><span>
</span><span id="line-313"></span><span class="annot"><a href="Data.Text.IO.html#putStrLn"><span class="hs-identifier hs-type">putStrLn</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-314"></span><span id="putStrLn"><span class="annot"><span class="annottext">putStrLn :: Text -&gt; IO ()
</span><a href="Data.Text.IO.html#putStrLn"><span class="hs-identifier hs-var hs-var">putStrLn</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Text -&gt; IO ()
</span><a href="Data.Text.IO.html#hPutStrLn"><span class="hs-identifier hs-var">hPutStrLn</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="../../base/src/GHC.IO.StdHandles.html#stdout"><span class="hs-identifier hs-var">stdout</span></a></span><span>
</span><span id="line-315"></span><span>
</span><span id="line-316"></span><span class="hs-comment">-- $locale</span><span>
</span><span id="line-317"></span><span class="hs-comment">--</span><span>
</span><span id="line-318"></span><span class="hs-comment">-- /Note/: The behaviour of functions in this module depends on the</span><span>
</span><span id="line-319"></span><span class="hs-comment">-- version of GHC you are using.</span><span>
</span><span id="line-320"></span><span class="hs-comment">--</span><span>
</span><span id="line-321"></span><span class="hs-comment">-- Beginning with GHC 6.12, text I\/O is performed using the system or</span><span>
</span><span id="line-322"></span><span class="hs-comment">-- handle's current locale and line ending conventions.</span><span>
</span><span id="line-323"></span><span class="hs-comment">--</span><span>
</span><span id="line-324"></span><span class="hs-comment">-- Under GHC 6.10 and earlier, the system I\/O libraries do not</span><span>
</span><span id="line-325"></span><span class="hs-comment">-- support locale-sensitive I\/O or line ending conversion.  On these</span><span>
</span><span id="line-326"></span><span class="hs-comment">-- versions of GHC, functions in this library all use UTF-8.  What</span><span>
</span><span id="line-327"></span><span class="hs-comment">-- does this mean in practice?</span><span>
</span><span id="line-328"></span><span class="hs-comment">--</span><span>
</span><span id="line-329"></span><span class="hs-comment">-- * All data that is read will be decoded as UTF-8.</span><span>
</span><span id="line-330"></span><span class="hs-comment">--</span><span>
</span><span id="line-331"></span><span class="hs-comment">-- * Before data is written, it is first encoded as UTF-8.</span><span>
</span><span id="line-332"></span><span class="hs-comment">--</span><span>
</span><span id="line-333"></span><span class="hs-comment">-- * On both reading and writing, the platform's native newline</span><span>
</span><span id="line-334"></span><span class="hs-comment">--   conversion is performed.</span><span>
</span><span id="line-335"></span><span class="hs-comment">--</span><span>
</span><span id="line-336"></span><span class="hs-comment">-- If you must use a non-UTF-8 locale on an older version of GHC, you</span><span>
</span><span id="line-337"></span><span class="hs-comment">-- will have to perform the transcoding yourself, e.g. as follows:</span><span>
</span><span id="line-338"></span><span class="hs-comment">--</span><span>
</span><span id="line-339"></span><span class="hs-comment">-- &gt; import qualified Data.ByteString as B</span><span>
</span><span id="line-340"></span><span class="hs-comment">-- &gt; import Data.Text (Text)</span><span>
</span><span id="line-341"></span><span class="hs-comment">-- &gt; import Data.Text.Encoding (encodeUtf16)</span><span>
</span><span id="line-342"></span><span class="hs-comment">-- &gt;</span><span>
</span><span id="line-343"></span><span class="hs-comment">-- &gt; putStr_Utf16LE :: Text -&gt; IO ()</span><span>
</span><span id="line-344"></span><span class="hs-comment">-- &gt; putStr_Utf16LE t = B.putStr (encodeUtf16LE t)</span><span>
</span><span id="line-345"></span><span class="hs-comment">--</span><span>
</span><span id="line-346"></span><span class="hs-comment">-- On transcoding errors, an 'IOError' exception is thrown. You can</span><span>
</span><span id="line-347"></span><span class="hs-comment">-- use the API in &quot;Data.Text.Encoding&quot; if you need more control over</span><span>
</span><span id="line-348"></span><span class="hs-comment">-- error handling or transcoding.</span><span>
</span><span id="line-349"></span></pre></body></html>